List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Waits till the Page gets the expected condition. * //from w ww . java 2 s . c o m * @param condition * the condition */ public static void waitforCondition(ExpectedCondition<Boolean> condition) { WebDriverWait wait = new WebDriverWait(getDriver(), Integer.parseInt(System.getProperty("explicit.wait"))); wait.until(condition); }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find clickable element.//from ww w . j a v a2 s. c o m * * @param by * (by element) * @return (clickable element) */ public WebElement findClickableElement(final By by) { WebElement clickableElement; try { clickableElement = (new WebDriverWait(this.driver, this.DEFAULT_TIMEOUT)) .until(ExpectedConditions.elementToBeClickable(by)); } catch (Throwable cause) { String errorMessage = "Could not find clickable element: " + by.toString(); this.logger.logWithScreenShot("findClickableElement failed.", this.driver); throw new RuntimeException(errorMessage); } return clickableElement; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find presence of the element in page. * //from ww w. j a v a 2 s.co m * @param by * (by element to be visible in page) * @param timeoutInSeconds * (timeout value in seconds) * @return presenceOfElement (Web element object of the presence element) */ public WebElement findPresenceOfElement(final By by, final int timeoutInSeconds) { WebElement presenceOfElement; try { presenceOfElement = (new WebDriverWait(this.driver, timeoutInSeconds)) .until(ExpectedConditions.presenceOfElementLocated(by)); } catch (Exception e) { String errorMessage = "Could not find presence of element: " + by.toString(); this.logger.logWithScreenShot("Could not find presence of element: " + by.toString(), this.driver); throw new RuntimeException(errorMessage); } return presenceOfElement; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find presence of the elements in page. * /* w ww.j a v a 2 s .com*/ * @param by * (by element to be visible in page) * @param timeoutInSeconds * (timeout value in seconds) * @return presenceOfElement (Web element object of the presence element) */ public List<WebElement> findPresenceOfElements(final By by, final int timeoutInSeconds) { List<WebElement> presenceOfElements; try { presenceOfElements = (new WebDriverWait(this.driver, timeoutInSeconds)) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)); } catch (Exception e) { String errorMessage = "Could not find presence of elements: " + by.toString(); this.logger.logWithScreenShot("Could not find presence of elements: ", this.driver); throw new RuntimeException(errorMessage); } return presenceOfElements; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find presence of inner text for the elements in page. * Can be used when elements vissibiliy is changed dynamically to make sure * that inner text is vissible./*from w ww . ja v a2 s . co m*/ * @param by * @param timeoutInSeconds * @return presenceOfElements */ public List<WebElement> findPresenceOfInnerTextForElements(final By by, final int timeoutInSeconds) { List<WebElement> presenceOfElements; final int waitForElement = timeoutInSeconds / 5; try { presenceOfElements = (new WebDriverWait(this.driver, timeoutInSeconds)) .until(new ExpectedCondition<List<WebElement>>() { @Override public List<WebElement> apply(WebDriver driver) { try { List<WebElement> elements = findPresenceOfElements(by, waitForElement); for (WebElement element : elements) { if (!StringUtils.hasText(element.getText())) { return null; } } return elements.size() > 0 ? elements : null; } catch (Throwable e) { return null; } } }); } catch (Exception e) { this.logger.logWithScreenShot("Could not find presence of elements: " + by.toString(), this.driver); throw new RuntimeException(e); } return presenceOfElements; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find visible element.//from w w w. ja v a2s . c o m * * @param by * (by element) * @return visibleElement (visible element) */ public WebElement findVisibleElement(final By by) { WebElement visibleElement; try { visibleElement = (new WebDriverWait(this.driver, this.DEFAULT_TIMEOUT)) .until(ExpectedConditions.visibilityOfElementLocated(by)); } catch (Throwable cause) { String errorMessage = "Could not find visible element: " + by.toString(); this.logger.logWithScreenShot("findVisibleElement failed.", this.driver); throw new RuntimeException(errorMessage); } return visibleElement; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find visible element in the page. * /* w w w .j a va 2s . c om*/ * @param by * (by element to be visible in page) * @param timeoutInSeconds * (timeout value in seconds) * @return visibleElement (Web element object of the visible element) */ public WebElement findVisibleElement(final By by, final int timeoutInSeconds) { WebElement visibleElement; try { visibleElement = (new WebDriverWait(this.driver, timeoutInSeconds)) .until(ExpectedConditions.visibilityOfElementLocated(by)); } catch (Throwable clause) { String errorMessage = "Could not find visible element: " + by.toString(); this.logger.logWithScreenShot("Could not find visible element: ", this.driver); throw new RuntimeException(errorMessage); } return visibleElement; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to return list of titles/get text for the given xpath. * * @param xpath//from ww w. j a v a 2 s . c o m * (xpath of elements) * @return List<String> list of titles of WebElements */ public List<String> getListOfTitlesForElementsWithGivenXPath(final String xpath) { this.logger.log("To get list of existing elements having xpath : " + xpath); List<String> listOfWebElementTitle = new ArrayList<String>(); List<WebElement> listOfElements = (new WebDriverWait(this.driver, 30)) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(xpath))); for (WebElement element : listOfElements) { if (element.getText() != null && element.getText().length() > 0) { listOfWebElementTitle.add(element.getText()); } } return listOfWebElementTitle; }
From source file:com.codenjoy.dojo.integration.IntegrationTest.java
License:Open Source License
private void sendChat(final String message) { driver.findElement(By.id("chat-message")).sendKeys(message); driver.findElement(By.id("chat-send")).click(); new WebDriverWait(driver, 500) { }.until(new ExpectedCondition<Object>() { @Override// w w w . j a v a2s.c o m public Object apply(@Nullable WebDriver driverObject) { return chat.getChatLog().toString().contains(message); } }); }
From source file:com.codenvy.corp.MainPage.java
License:Open Source License
public void gotoMainPageWaitAuthorizePageAndLogin(String login, String passWord) throws InterruptedException { driver.get(baseUrl);//from w w w .j a v a 2 s . c o m new WebDriverWait(driver, 40) .until(ExpectedConditions.visibilityOfAllElements(Arrays.asList(loginField, passField))); loginField.sendKeys(login); passField.sendKeys(passWord); loginBtnb.click(); Thread.sleep(15000); new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Agile"))) .click(); initId(); }