List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.hotwire.selenium.angular.AngularGlobalHeader.java
License:Open Source License
public void selectCountry(String country) { new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".country-dropdown a.dropdown-toggle"))); getWebDriver().findElement(By.cssSelector(".country-dropdown a.dropdown-toggle")).click(); new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".country-dropdown ul.dropdown-menu li a"))); boolean found = false; for (WebElement countryListItem : getWebDriver() .findElements(By.cssSelector(".country-dropdown ul.dropdown-menu li a"))) { if (countryListItem.getText().trim().toLowerCase().equals(country.toLowerCase())) { found = true;/*from w w w .ja va 2s. c o m*/ countryListItem.click(); break; } } if (!found) { throw new RuntimeException("\"" + country + "\" is not a valid country selector."); } }
From source file:com.hotwire.selenium.angular.AngularGlobalHeader.java
License:Open Source License
public void selectCurrency(String currency) { new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".currency-dropdown a.dropdown-toggle"))); getWebDriver().findElement(By.cssSelector(".currency-dropdown a.dropdown-toggle")).click(); new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".currency-dropdown ul.dropdown-menu li a"))); boolean found = false; for (WebElement currencyListItem : getWebDriver() .findElements(By.cssSelector(".currency-dropdown ul.dropdown-menu li a"))) { if (currencyListItem.getText().trim().startsWith(currency)) { found = true;/* www . j a va2s .c o m*/ currencyListItem.click(); break; } } if (!found) { throw new RuntimeException("\"" + currency + "\" is not a valid currency selector."); } }
From source file:com.hotwire.selenium.angular.AngularGlobalHeader.java
License:Open Source License
public String getSelectedCurrency() { new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".currency-dropdown a.dropdown-toggle"))); return getWebDriver().findElement(By.cssSelector(".currency-dropdown a.dropdown-toggle")).getText(); }
From source file:com.hotwire.selenium.angular.AngularGlobalHeader.java
License:Open Source License
public void selectMyAccountItem(String menuSelection) { new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".sign-in-dropdown a.dropdown-toggle"))); getWebDriver().findElement(By.cssSelector(".sign-in-dropdown a.dropdown-toggle")).click(); new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".sign-in-dropdown ul.dropdown-menu li a"))); boolean found = false; for (WebElement element : getWebDriver() .findElements(By.cssSelector(".sign-in-dropdown ul.dropdown-menu li a"))) { if (element.getText().trim().equals(menuSelection)) { found = true;/*from w w w . j av a 2s .c om*/ element.click(); break; } } if (!found) { throw new RuntimeException(menuSelection + " My Account selector is not available."); } }
From source file:com.hotwire.selenium.angular.AngularGlobalHeader.java
License:Open Source License
public void selectSupportItem(String supportType) { new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".support-dropdown a.dropdown-toggle"))); getWebDriver().findElement(By.cssSelector(".support-dropdown a.dropdown-toggle")).click(); new WebDriverWait(getWebDriver(), 2) .until(new VisibilityOf(By.cssSelector(".support-dropdown ul.dropdown-menu li a"))); boolean found = false; for (WebElement element : getWebDriver() .findElements(By.cssSelector(".support-dropdown ul.dropdown-menu li a"))) { if (element.getText().trim().equals(supportType)) { found = true;//from w w w .j a v a 2s .c o m element.click(); break; } } if (!found) { throw new RuntimeException(supportType + " Support selector is not available."); } }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected WebElement findOne(By seleniumByObject, int timeInSeconds) { return new WebDriverWait(getWebDriver(), timeInSeconds) .until(ExpectedConditions.visibilityOfElementLocated(seleniumByObject)); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected List<WebElement> findMany(String cssSelector, int timeInSeconds) { return new WebDriverWait(getWebDriver(), timeInSeconds) .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(cssSelector))); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected List<WebElement> findMany(By seleniumObject, int timeInSeconds) { return new WebDriverWait(getWebDriver(), timeInSeconds) .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(seleniumObject)); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
/** * Use it if select on webpage is invisible and decorated by links * @param selectLinkCss - visible selector link * @param linkText - text of the link in selector *///from w w w. j a va 2 s . com protected void selectLink(String selectLinkCss, String linkText) { getWebDriver().findElement(By.cssSelector(selectLinkCss)).click(); new WebDriverWait(getWebDriver(), DEFAULT_WAIT) .until(ExpectedConditions.visibilityOfElementLocated(By.linkText(linkText))).click(); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected void clickOnLink(String linkText, int waitTimeout) { new WebDriverWait(getWebDriver(), waitTimeout) .until(ExpectedConditions.visibilityOfElementLocated(By.linkText(linkText))).click(); }