List of usage examples for org.openqa.selenium.support.ui ExpectedConditions alertIsPresent
public static ExpectedCondition<Alert> alertIsPresent()
From source file:com.pentaho.ctools.cdf.TextInputComponent.java
License:Apache License
/** * ############################### Test Case 3 ############################### * * Test Case Name:// ww w . j a va 2 s . c o m * Insert a small text * Description: * We pretend validate when we insert a small text an alert is raised. * Steps: * 1. Insert text * 2. Check for alert * 3. Check the input text inserted */ @Test public void tc3_InputSmallPhrase_AlertDispayed() { // ## Step 1 String strInputString = "Hello World!"; this.elemHelper.FindElement(driver, By.id("myInput")).clear(); this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(strInputString); this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(Keys.ENTER); // ## Step 2 wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); String expectedCnfText = "you typed: " + strInputString; alert.accept(); assertEquals(expectedCnfText, confirmationMsg); }
From source file:com.pentaho.ctools.cdf.TextInputComponent.java
License:Apache License
/** * ############################### Test Case 4 ############################### * * Test Case Name:/*from ww w .j a v a 2 s . c om*/ * Insert a long text * Description: * We pretend validate when we insert a long text an alert is raised. * Steps: * 1. Insert text * 2. Check for alert * 3. Check the input text inserted */ @Test public void tc4_InputLongPhrase_AlertDispayed() { // ## Step 1 String strInputString = "Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!"; strInputString += strInputString; strInputString += strInputString; strInputString += strInputString; strInputString += strInputString; this.elemHelper.FindElement(driver, By.id("myInput")).clear(); //After clean text, we need to trait the pop-up wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); alert.accept(); this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(strInputString); this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(Keys.ENTER); // ## Step 2 wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); String expectedCnfText = "you typed: " + strInputString; alert.accept(); assertEquals(expectedCnfText, confirmationMsg); }
From source file:com.pentaho.ctools.cdf.TextInputComponent.java
License:Apache License
/** * ############################### Test Case 5 ############################### * * Test Case Name:// w ww.j a v a 2 s . c om * Insert special characters * Description: * We pretend validate when we insert a special characters an alert is * raised. * Steps: * 1. Insert text * 2. Check for alert * 3. Check the input text inserted */ @Test public void tc5_InputSpecialPhrase_AlertDispayed() { // ## Step 1 String strInputString = "`|!\"1#$%&/()=?*:_<>/*-+"; this.elemHelper.FindElement(driver, By.id("myInput")).clear(); //After clean text, we need to trait the pop-up wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); alert.accept(); this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(strInputString); this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(Keys.ENTER); // ## Step 2 wait.until(ExpectedConditions.alertIsPresent()); alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); String expectedCnfText = "you typed: " + strInputString; alert.accept(); assertEquals(expectedCnfText, confirmationMsg); }
From source file:com.seleniumtests.uipage.BasePage.java
License:Apache License
public Alert getAlert() { new WebDriverWait(driver, 2).until(ExpectedConditions.alertIsPresent()); return driver.switchTo().alert(); }
From source file:cuenen.raymond.svgplot.ExpressionParserTest.java
License:CDDL license
/** * Convenience method to evaluate an expression. * * @param driver The WebDriver executing the test. * @param expression The expression to be parsed. * @param value The value to use with variable substitution. * @param alert {@code true} when an alert is expected, {@code false} * otherwise./*from w ww. ja va2 s. c om*/ * @return The parsed result. */ private String evaluateExpression(WebDriver driver, String expression, String value, boolean alert) { Wait wait = load(driver, MODULE_LOADER, 1); String callback = String.format(FUNCTION_FORMAT, expression, value); require(driver, callback, MODULE_NAME); if (alert) { wait.until(ExpectedConditions.alertIsPresent()); return getAlert(driver); } else { wait.until(RESULT_SET); return getResult(driver); } }
From source file:cuenen.raymond.svgplot.SVGPlotAttributesTest.java
License:CDDL license
/** * Verify the error when parsing the attribute twice. * * @param driver The WebDriver executing the test. *///from w ww.java 2 s. c o m @Test(dataProvider = "driver", groups = { "all", "alert" }) public void multipleAttributesTest(WebDriver driver) { String msg = getMessage(driver); for (String[] attribute : VALID_ATTRIBUTES) { Wait wait = parseAttribute(driver, attribute[0], attribute[1], 2); wait.until(ExpectedConditions.alertIsPresent()); String alert = getAlert(driver); assertTrue(alert.startsWith(String.format(ALREADY_SET, attribute[0])), msg + ": " + attribute[0] + " --> " + alert); } }
From source file:cuenen.raymond.svgplot.SVGPlotAttributesTest.java
License:CDDL license
/** * Verify the exceptions when an invalid attribute value is supplied. * * @param driver The WebDriver executing the test. *///from w w w .ja v a 2 s . c o m @Test(dataProvider = "driver", groups = { "all", "alert" }) public void invalidAttributesTest(WebDriver driver) { String msg = getMessage(driver); for (String[] attribute : INVALID_ATTRIBUTES) { Wait wait = parseAttribute(driver, attribute[0], attribute[1], 1); wait.until(ExpectedConditions.alertIsPresent()); String alert = getAlert(driver); assertTrue(alert.startsWith(attribute[2]), msg + ": " + attribute[0] + " --> " + alert); } }
From source file:cuenen.raymond.svgplot.SVGPlotAttributesTest.java
License:CDDL license
/** * Verify the exception of creating an unknown attribute. * * @param driver The WebDriver executing the test. *//*from www . jav a 2 s.c o m*/ @Test(dataProvider = "driver", groups = { "all", "alert" }) public void unknownAttributeTest(WebDriver driver) { Wait wait = parseAttribute(driver, UNKNOWN_ATTRIBUTE[0], UNKNOWN_ATTRIBUTE[1], 0); wait.until(ExpectedConditions.alertIsPresent()); String alert = getAlert(driver); String msg = getMessage(driver); assertTrue(alert.startsWith(UNKNOWN_ATTRIBUTE[2]), msg + ": " + UNKNOWN_ATTRIBUTE[0] + " --> " + alert); }
From source file:cuenen.raymond.svgplot.SVGPlotAttributesTest.java
License:CDDL license
/** * Test for failure of a newly defined attribute. * * @param driver The WebDriver executing the test. */// ww w.j a va 2 s . c o m @Test(dataProvider = "driver", groups = { "all", "alert" }) public void invalidNewAttributeTest(WebDriver driver) { Wait wait = load(driver, MODULE_LOADER, 1); String callback = String.format(SET_FUNCTION_FORMAT, NEW_ATTRIUTE[0], NEW_ATTRIUTE[1], "{parse: function(a){return a;}}", UNKNOWN_ATTRIBUTE[1]); require(driver, callback, MODULE_NAME); wait.until(ExpectedConditions.alertIsPresent()); String msg = getMessage(driver); String alert = getAlert(driver); assertTrue(alert.startsWith("TypeError: Invalid parse function"), msg + " --> " + alert); }
From source file:cuenen.raymond.svgplot.SVGPlotModuleTest.java
License:CDDL license
/** * Test for an error when the SVGModule loader cannot load a module. * * @param driver The WebDriver executing the test. *///from www . j a va2 s . co m @Test(dataProvider = "driver", groups = { "all", "alert" }) public void testSVGPlotModuleWithError(WebDriver driver) { Wait wait = load(driver, MODULE_LOADER, 1); require(driver, TEST_MODULE_CALLBACK, TEST_MODULE_NAME + "2"); wait.until(ExpectedConditions.alertIsPresent()); String alert = getAlert(driver); String msg = getMessage(driver); assertTrue(alert.startsWith(ERROR_MESSAGE), msg + " --> " + alert); }