Search in sources :

Example 26 with Alert

use of org.openqa.selenium.Alert in project openmeetings by apache.

the class TestSignUp method testSignUp.

@Test
public void testSignUp() throws Exception {
    try {
        driver.get(getBASE_URL());
        String currentRandomCounter = "" + ((new Date().getTime()) / 1000);
        String userName = "seba" + currentRandomCounter;
        String email = "hans." + currentRandomCounter + "@openmeetings.apache.org";
        super.testIsInstalledAndDoInstallation();
        WebElement signUpButton = SeleniumUtils.findElement(driver, "//button[span[contains(text(), '" + getString("123") + "')]]", true, true);
        signUpButton.click();
        // ##################################
        // Test validation message for passwords to be identical
        // ##################################
        doSignUp("Hans", "Muster", userName, "pw", "pw2", email);
        // Find Error label-id 232 "Please enter two identical passwords"
        SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("232") + "')]", true, true);
        // ##################################
        // Sign up with user and sign in
        // ##################################
        doSignUp("Hans", "Muster", userName, pass, pass, email);
        // Check for popup with success message and email to check
        SeleniumUtils.findElement(driver, "//span[contains(text(), '" + getString("warn.notverified") + "')]", true, true);
        // click button to close popup
        WebElement signUpSucessPopUpOkButton = SeleniumUtils.findElement(driver, "//button[span[contains(text(), '" + DialogButtons.OK.toString() + "')]]", true, true);
        signUpSucessPopUpOkButton.click();
        // Login with user
        SeleniumUtils.inputText(driver, "login", userName);
        SeleniumUtils.inputText(driver, "pass", pass);
        // click labelid 112 "Sign In"
        WebElement signInButton = SeleniumUtils.findElement(driver, "//button[span[contains(text(), '" + getString("112") + "')]]", true, true);
        signInButton.click();
        // check for some text in dashbaord, labelid 281, "Help and support"
        SeleniumUtils.elementExists(driver, "//h3[contains(text(), '" + getString("281") + "')]", true);
        // sign out
        WebElement signOutLink = SeleniumUtils.findElement(driver, "//a[contains(text(), '" + getString("310") + "')]", true, true);
        signOutLink.click();
        Alert alert = driver.switchTo().alert();
        alert.accept();
        // ##################################
        // Sign up with same user and email and check duplicate messages
        // ##################################
        signUpButton = SeleniumUtils.findElement(driver, "//button[span[contains(text(), '" + getString("123") + "')]]", true, true);
        signUpButton.click();
        doSignUp("Hans", "Muster", userName, pass, pass, email);
        SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("error.login.inuse") + "')]", true, true);
        SeleniumUtils.findElement(driver, "//span[@class='feedbackPanelERROR'][contains(text(), '" + getString("error.email.inuse") + "')]", true, true);
    } catch (Exception e) {
        SeleniumUtils.makeScreenShot(this.getClass().getSimpleName(), e, driver);
        throw e;
    }
}
Also used : Alert(org.openqa.selenium.Alert) WebElement(org.openqa.selenium.WebElement) Date(java.util.Date) Test(org.junit.Test)

Example 27 with Alert

use of org.openqa.selenium.Alert in project edx-app-android by edx.

the class NativeAppDriver method acceptAlert.

/**
 * Accept the alert
 */
public void acceptAlert() {
    WebDriverWait wait = (WebDriverWait) new WebDriverWait(appiumDriver, maxWaitTime, 500);
    wait.until(ExpectedConditions.alertIsPresent());
    Alert alrt = appiumDriver.switchTo().alert();
    alrt.accept();
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Alert(org.openqa.selenium.Alert)

Example 28 with Alert

use of org.openqa.selenium.Alert in project keycloak by keycloak.

the class WebAuthnRegisterPage method isRegisterAlertPresent.

public boolean isRegisterAlertPresent(long seconds) {
    try {
        // label edit after registering authenticator by .create()
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(seconds));
        Alert promptDialog = wait.until(ExpectedConditions.alertIsPresent());
        assertThat(promptDialog.getText(), CoreMatchers.is("Please input your registered authenticator's label"));
        return true;
    } catch (TimeoutException e) {
        return false;
    }
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Alert(org.openqa.selenium.Alert) TimeoutException(org.openqa.selenium.TimeoutException)

Example 29 with Alert

use of org.openqa.selenium.Alert in project liferay-blade-samples by liferay.

the class BladeSampleFunctionalActionUtil method isAlertPresent.

public static boolean isAlertPresent(WebDriver webDriver) {
    try {
        WebDriverWait webDriverWait = new WebDriverWait(webDriver, 15);
        Alert alert = webDriverWait.until(ExpectedConditions.alertIsPresent());
        if (alert != null) {
            webDriver.switchTo().alert().accept();
            return true;
        } else {
            throw new NoAlertPresentException();
        }
    } catch (NoAlertPresentException nape) {
        return false;
    }
}
Also used : NoAlertPresentException(org.openqa.selenium.NoAlertPresentException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Alert(org.openqa.selenium.Alert)

Aggregations

Alert (org.openqa.selenium.Alert)29 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)10 Test (org.junit.Test)7 NoAlertPresentException (org.openqa.selenium.NoAlertPresentException)5 WebDriver (org.openqa.selenium.WebDriver)5 WebElement (org.openqa.selenium.WebElement)5 By (org.openqa.selenium.By)4 WebDriverException (org.openqa.selenium.WebDriverException)4 Test (org.testng.annotations.Test)4 Method (java.lang.reflect.Method)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2 CoreMatchers (org.hamcrest.CoreMatchers)2 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)2 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)2 TimeoutException (org.openqa.selenium.TimeoutException)2 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)2 ExpectedConditions (org.openqa.selenium.support.ui.ExpectedConditions)2 ITestResult (org.testng.ITestResult)2 AfterMethod (org.testng.annotations.AfterMethod)2