Example usage for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated

Introduction

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

Prototype

public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator) 

Source Link

Document

An expectation for checking that an element is present on the DOM of a page.

Usage

From source file:com.zaizi.sensefymobile.ios.core.elements.Element.java

License:Open Source License

/**
 * Wait Until Element is present by locator
 *//*www.j  a  va 2s  .  c o m*/
public static void waitUntilElementPresent(WebDriver driver, By locator) {
    //   WebElement myDynamicElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(xPath));
    WebElement myDynamicElement = (new WebDriverWait(driver, 20))
            .until(ExpectedConditions.presenceOfElementLocated(locator));

    // By.xpath("//body//div//div//div//span[contains(.,'Enter at least 1')]"));
    // Thread.sleep(3000);
}

From source file:com.zutubi.pulse.acceptance.SeleniumBrowser.java

License:Apache License

public WebElement waitForElement(final By by, long timeout) {
    Wait<WebDriver> wait = new WebDriverWait(webDriver, timeout / 1000, 250).ignoring(RuntimeException.class);
    return wait.until(ExpectedConditions.presenceOfElementLocated(by));
}

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  ww  .  j a  v a2s.co m
@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.//w  ww  .ja va2  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 w  w.ja  v  a2s  . co  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.
 *///from   ww w  . j  a  va 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:de.codecentric.zucchini.web.steps.WaitForStep.java

License:Apache License

/**
 * Waits for the element./*  w  ww .  j  a v a  2 s .  c  o m*/
 */
@Override
public void go() {
    logger.info("Waiting {} seconds for {}...", timeout, element);
    WebDriverWait waiting = new WebDriverWait(getWebDriver(), timeout);
    try {
        waiting.until(ExpectedConditions.presenceOfElementLocated(element));
    } catch (NullPointerException e) {
        fail(String.format("Element %s did not appear within %d seconds.", element, timeout), e);
    }
}

From source file:de.knowwe.uitest.DiaFluxUITest.java

License:Open Source License

private void createNextFlow() {
    new WebDriverWait(getDriver(), 5)
            .until(ExpectedConditions.presenceOfElementLocated(By.linkText("Click here to create one.")))
            .click();//from  w w  w.  j  av  a  2  s  .c o m
}

From source file:de.knowwe.uitest.DiaFluxUITest.java

License:Open Source License

protected void switchToEditor(String articleHandle) throws InterruptedException {
    new WebDriverWait(getDriver(), 10).until((WebDriver driver) -> driver.getWindowHandles().size() == 2);
    Set<String> windowHandles = new HashSet<>(getDriver().getWindowHandles());
    windowHandles.remove(articleHandle);
    getDriver().switchTo().window(windowHandles.iterator().next());
    new WebDriverWait(getDriver(), 10)
            .until(ExpectedConditions.presenceOfElementLocated(By.id("start_prototype")));
}

From source file:de.knowwe.uitest.KnowWEUITest.java

License:Open Source License

protected void changeArticleText(String newText) {
    new WebDriverWait(getDriver(), 10)
            .until(ExpectedConditions.presenceOfElementLocated(By.id("edit-source-button")));
    getDriver().findElement(By.id("edit-source-button")).click();
    UITestUtils.enterArticleText(newText, getDriver(), getTemplate());
}