Example usage for org.openqa.selenium.support.ui Wait until

List of usage examples for org.openqa.selenium.support.ui Wait until

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui Wait until.

Prototype

<T> T until(Function<? super F, T> isTrue);

Source Link

Document

Implementations should wait until the condition evaluates to a value that is neither null nor false.

Usage

From source file:cuenen.raymond.svgplot.SVGPlotAttributesTest.java

License:CDDL license

/**
 * Test the result of the 'names' interface function.
 *
 * @param driver The WebDriver executing the test.
 *///from  w  ww.j a v  a2 s  .  c o  m
@Test(dataProvider = "driver", groups = "all")
public void namesTest(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER, 1);
    require(driver, NAMES_FUNCTION, MODULE_NAME);
    wait.until(RESULT_SET);
    String msg = getMessage(driver);
    String result = getResult(driver);
    assertNotNull(result, msg);
    List<String> names = new ArrayList<>(Arrays.asList(result.split(",")));
    for (String[] attr : VALID_ATTRIBUTES) {
        assertTrue(names.contains(attr[0]), msg + ": " + attr[0]);
        names.remove(attr[0]);
    }
    assertTrue(names.isEmpty(), msg);
}

From source file:cuenen.raymond.svgplot.SVGPlotAttributesTest.java

License:CDDL license

/**
 * Run the attribute test. This test will create the attribute three times:
 * <ol>/*from  www.  ja  va2 s .  c o m*/
 * <li>Retrieve the default value.
 * <li>Parse and retrieve the value.
 * <li>Parse twice and verify the exception.
 * </ol>
 *
 * @param driver The WebDriver executing the test.
 * @param attribute The attribute description [name, string, default,
 * parsed].
 * @param msg The error message to use.
 */
private void run(WebDriver driver, String[] attribute, String msg) {
    Wait wait = parseAttribute(driver, attribute[0], attribute[1], 0);
    wait.until(RESULT_SET);
    assertEquals(getResult(driver), attribute[2], msg + ": " + attribute[0]);
    wait = parseAttribute(driver, attribute[0], attribute[1], 1);
    wait.until(RESULT_SET);
    assertEquals(getResult(driver), attribute[3], msg + ": " + attribute[0]);
}

From source file:cuenen.raymond.svgplot.SVGPlotHandlerTest.java

License:CDDL license

/**
 * Test the SVGPlothandler. Note that this module has no interface.
 *
 * @param driver The WebDriver executing the test.
 *//*from  w  w  w  .  ja v  a  2  s.  c  om*/
@Test(dataProvider = "driver", groups = "all")
public void handlerTest(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER_PLOT, 1);
    String callback = String.format(CALLBACK_FORMAT, DONE_SCRIPT);
    require(driver, callback, MODULE_NAME);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(DONE_ID)));
    validateResult(driver);
}

From source file:cuenen.raymond.svgplot.SVGPlotHandlerTest.java

License:CDDL license

/**
 * Test that the SVGPlotHandler also handles plot elements when added after
 * loading./* ww  w .  jav a  2  s . c  o  m*/
 *
 * @param driver The WebDriver executing the test.
 */
@Test(dataProvider = "driver", groups = "all")
public void changeTest(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER_PLOT, 1);
    String callback = String.format(CALLBACK_FORMAT, APPEND_SCRIPT);
    require(driver, callback, MODULE_NAME);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(APPEND_ID)));
    validateResult(driver);
    WebElement path = getElementById(driver, APPEND_ID);
    validatePath(path.getAttribute("d"), X_SIN, -Math.PI, Math.PI, 25);
}

From source file:cuenen.raymond.svgplot.SVGPlotModuleTest.java

License:CDDL license

/**
 * Test the SVGModule loader with 'moduleBase' attribute.
 *
 * @param driver The WebDriver executing the test.
 *//*from   w  ww .j  a va2 s.c o m*/
@Test(dataProvider = "driver", groups = "all")
public void testSVGPlotModuleLoaderWithBase(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER_WITH_BASE, 1);
    require(driver, TEST_MODULE_CALLBACK, TEST_MODULE_NAME);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(TEST_MODULE_ID)));
}

From source file:cuenen.raymond.svgplot.SVGPlotModuleTest.java

License:CDDL license

/**
 * Test the SVGModule loader when modules are relative to the document.
 *
 * @param driver The WebDriver executing the test.
 *///  ww w  .java  2  s.  c  o  m
@Test(dataProvider = "driver", groups = "all")
public void testSVGPlotModuleRelative(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER_RELATIVE, 1);
    require(driver, TEST_MODULE_CALLBACK, TEST_MODULE_NAME);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(TEST_MODULE_ID)));
}

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.
 *///w  w  w.ja v a  2  s. c o 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);
}

From source file:cuenen.raymond.svgplot.SVGPlotterTest.java

License:CDDL license

/**
 * Test the handling of plot elements./*w w  w . j a v  a  2s .  c  om*/
 *
 * @param driver The WebDriver executing the test.
 */
@Test(dataProvider = "driver", groups = "all", expectedExceptions = NoSuchElementException.class)
public void handlePlotElementTest(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER, 1);
    StringBuilder plot = new StringBuilder(CREATE_ELEMENT);
    addAttribute(plot, "stroke", "black");
    addAttribute(plot, "domain", "-1:1");
    addAttribute(plot, "samples", "10");
    addAttribute(plot, "function", "#t^2,atan(#t)");
    addAttribute(plot, "variable", "t");
    addAttribute(plot, "id", "plot-element");
    String callback = String.format(CALLBACK, plot.toString());
    require(driver, callback, MODULE_NAME);
    wait.until(RESULT_SET);
    assertEquals(getResult(driver), "[object SVGPathElement]", getMessage(driver));
    getElementById(driver, "plot-element");
}

From source file:cuenen.raymond.svgplot.SVGPlotterTest.java

License:CDDL license

/**
 * Test the replacement of plot elements in the SVGDocument.
 *
 * @param driver The WebDriver executing the test.
 *///from w  w w  . j  a  va2  s .c o  m
@Test(dataProvider = "driver", groups = "all")
public void handleAndReplaceTest(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER, 1);
    StringBuilder plot = new StringBuilder(CREATE_ELEMENT);
    addAttribute(plot, "stroke", "blue");
    addAttribute(plot, "stroke-width", "0.05");
    addAttribute(plot, "fill", "none");
    addAttribute(plot, "domain", "0:2");
    addAttribute(plot, "samples", "10");
    addAttribute(plot, "function", "0.5*#x^2-1");
    addAttribute(plot, "id", "plot-element");
    addAttribute(plot, "transform", "translate(100, 250) scale(100)");
    plot.append("document.documentElement.appendChild(el);");
    String callback = String.format(CALLBACK, plot.toString());
    require(driver, callback, MODULE_NAME);
    wait.until(RESULT_SET);
    WebElement path = getElementById(driver, "plot-element");
    validatePath(path.getAttribute("d"), X_HALFSQUAREDMINUS1, 0, 2, 10);
}

From source file:cuenen.raymond.svgplot.SVGPlotterTest.java

License:CDDL license

/**
 * Test for an error when there is no 'function' attribute specified.
 *
 * @param driver The WebDriver executing the test.
 *//*from ww w.  j  a  v  a 2  s  .  c  om*/
@Test(dataProvider = "driver", groups = { "all", "alert" })
public void handleNoFunctionTest(WebDriver driver) {
    Wait wait = load(driver, MODULE_LOADER, 1);
    StringBuilder elem = new StringBuilder(CREATE_ELEMENT);
    addAttribute(elem, "samples", "100");
    String callback = String.format(CALLBACK, elem.toString());
    require(driver, callback, MODULE_NAME);
    wait.until(ExpectedConditions.alertIsPresent());
    String alert = getAlert(driver);
    String msg = getMessage(driver);
    assertTrue(alert.startsWith("NotFoundError: Function not set: <plot samples=\"100\" />"),
            msg + " --> " + alert);
}