Search in sources :

Example 6 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project selenium-tests by Wikia.

the class CreateNewWikiPageObjectStep3 method submit.

public ArticlePageObject submit() {
    changeImplicitWait(250, TimeUnit.MILLISECONDS);
    try {
        new WebDriverWait(driver, 180).until(CommonExpectedConditions.elementNotPresent(loadingIndicatorBy));
    } finally {
        restoreDefaultImplicitWait();
    }
    scrollAndClick(submitButton);
    PageObjectLogging.log("submit", "Submit button clicked", true, driver);
    return new ArticlePageObject();
}
Also used : ArticlePageObject(com.wikia.webdriver.pageobjectsfactory.pageobject.article.ArticlePageObject) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 7 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project SneakerBot by Penor.

the class Adidas method atc.

public void atc() {
    WebDriverWait wait = new WebDriverWait(driver, 300L);
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@class='ffSelectButton' and (.//span[text()[contains(.,'Size')]] or .//span[text()[contains(.,'size')]])]")));
    int index = new Random().nextInt(sizes.length);
    String sizeToPick = Double.toString(sizes[index]);
    for (WebElement e : driver.findElements(By.xpath("//div[@class='ffSelectMenuMid' and .//ul[.//li[.//span[text()[contains(.,'size')]]]]]/ul/li"))) {
        String size = e.getText().trim();
        if (size != null && size.equals(sizeToPick)) {
            e.click();
            break;
        }
    }
}
Also used : Random(java.util.Random) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Example 8 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project rstudio by rstudio.

the class MenuNavigator method getMenuItem.

public static WebElement getMenuItem(final WebDriver driver, String level1, String level2, String level3) {
    WebElement popupItem = getMenuItem(driver, level1, level2);
    Actions action = new Actions(driver);
    action.moveToElement(popupItem).build().perform();
    // Wait for there to be two popups open (the level1 and level2 menus)
    (new WebDriverWait(driver, 1)).until(new ExpectedCondition<Boolean>() {

        public Boolean apply(WebDriver d) {
            List<WebElement> elements = driver.findElements(By.className("gwt-MenuBarPopup"));
            return elements.size() > 1;
        }
    });
    // Get the second popup menu
    List<WebElement> elements = driver.findElements(By.className("gwt-MenuBarPopup"));
    WebElement menu2popup = elements.get(1);
    return findMenuItemByName(menu2popup, level3);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Actions(org.openqa.selenium.interactions.Actions) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) List(java.util.List) WebElement(org.openqa.selenium.WebElement)

Example 9 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project ORCID-Source by ORCID.

the class OauthAuthorizationPageHelper method clickAuthorizeOnAuthorizeScreen.

private static void clickAuthorizeOnAuthorizeScreen(final WebDriver webDriver) {
    By userIdElementLocator = By.id("authorize");
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(userIdElementLocator));
    WebElement authorizeButton = webDriver.findElement(By.id("authorize"));
    authorizeButton.click();
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {

        public Boolean apply(WebDriver d) {
            return d.getTitle().equals("ORCID Playground");
        }
    });
}
Also used : WebDriver(org.openqa.selenium.WebDriver) By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Example 10 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project ORCID-Source by ORCID.

the class BlackBoxBase method changeNamesVisibility.

public static void changeNamesVisibility(Visibility changeTo) throws Exception {
    int privacyIndex = getPrivacyIndex(changeTo);
    try {
        By openEditNames = By.xpath("//div[@id = 'names-section']//div[@id = 'open-edit-names']");
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(openEditNames));
        WebElement openEditNamesElement = webDriver.findElement(openEditNames);
        openEditNamesElement.click();
        By namesVisibility = By.xpath("//div[@id = 'names-section']//ul[@class='privacyToggle']/li[" + privacyIndex + "]/a");
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(namesVisibility));
        WebElement namesVisibilityElement = webDriver.findElement(namesVisibility);
        namesVisibilityElement.click();
        By saveButton = By.xpath("//div[@id = 'names-section']//ul[@class='workspace-section-toolbar']//li[1]//button");
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(saveButton));
        WebElement button = webDriver.findElement(saveButton);
        button.click();
        Thread.sleep(1000);
    } catch (Exception e) {
        System.out.println("Unable to find names-visibility-limited element");
        e.printStackTrace();
        throw e;
    }
}
Also used : By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException) JSONException(org.codehaus.jettison.json.JSONException)

Aggregations

WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)556 WebElement (org.openqa.selenium.WebElement)173 WebDriver (org.openqa.selenium.WebDriver)139 Test (org.junit.Test)88 By (org.openqa.selenium.By)58 Actions (org.openqa.selenium.interactions.Actions)54 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)47 TimeoutException (org.openqa.selenium.TimeoutException)41 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)38 IOException (java.io.IOException)30 List (java.util.List)27 Wait (org.openqa.selenium.support.ui.Wait)25 BeforeClass (org.junit.BeforeClass)24 NgWebDriver (com.github.sergueik.jprotractor.NgWebDriver)21 ArrayList (java.util.ArrayList)21 WebDriverException (org.openqa.selenium.WebDriverException)21 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)21 Dimension (org.openqa.selenium.Dimension)20 File (java.io.File)18 NoSuchElementException (org.openqa.selenium.NoSuchElementException)16