Search in sources :

Example 71 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project devonfw-testing by devonfw.

the class DriverExtention method findElementsDynamic.

public List<WebElement> findElementsDynamic(By by, int timeOut) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebDriverWait wait = webDriverWait(timeOut);
    List<WebElement> elements = new ArrayList<WebElement>();
    try {
        elements = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(by));
    } catch (BFElementNotFoundException | TimeoutException e) {
        throw new BFElementNotFoundException(by, true, timeOut);
    }
    if (elements.isEmpty()) {
        BFLogger.logError("Not found element : " + by.toString() + ".");
    }
    BFLogger.logTime(startTime, "findElementDynamics()", by.toString());
    return elements;
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException)

Example 72 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project devonfw-testing by devonfw.

the class DriverExtention method findElementDynamicBasic.

private WebElement findElementDynamicBasic(By by, long startTime, int timeOut) throws BFElementNotFoundException {
    WebElement element = null;
    WebDriverWait wait = webDriverWait(timeOut);
    try {
        element = wait.until(ExpectedConditions.presenceOfElementLocated(by));
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(by, isTimeout, timeOut);
    }
    BFLogger.logTime(startTime, "findElementDynamic()", by.toString());
    return element;
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 73 with WebDriverWait

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

the class AbstractArchivaTest method deleteUser.

public void deleteUser(String userName, String fullName, String emailAd, boolean validated, boolean locked) {
    clickLinkWithLocator("menu-users-list-a");
    WebDriverWait wait = new WebDriverWait(getWebDriver(), 10);
    wait.until(ExpectedConditions.elementToBeClickable(By.id("users-grid-delete-" + userName)));
    assertTextPresent(userName);
    assertTextPresent(fullName);
    clickLinkWithLocator("users-grid-delete-" + userName);
    wait.until(ExpectedConditions.elementToBeClickable(By.id("dialog-confirm-modal-ok")));
    clickLinkWithLocator("dialog-confirm-modal-ok");
    wait.until(ExpectedConditions.elementToBeClickable(By.id("alert-message-success-close-a")));
    assertTextPresent("User " + userName + " deleted.");
    clickLinkWithLocator("alert-message-success-close-a");
    assertElementNotPresent("users-grid-user-id-" + userName);
    assertTextNotPresent(fullName);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 74 with WebDriverWait

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

the class AbstractArchivaTest method logout.

protected void logout() {
    clickLinkWithLocator("logout-link-a");
    WebDriverWait wait = new WebDriverWait(getWebDriver(), 10);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[text()='Login']//ancestor::a")));
    assertTextNotPresent("Current User:");
    assertLinkNotVisible("Edit Details");
    assertLinkNotVisible("Logout");
    assertLinkVisible("Login");
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 75 with WebDriverWait

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

the class AbstractSeleniumTest method selectValue.

public WebElement selectValue(String locator, String value, boolean scrollToView) {
    int count = 5;
    boolean check = true;
    WebDriverWait wait = new WebDriverWait(getWebDriver(), 10);
    WebElement element = null;
    while (check && count-- > 0) {
        try {
            element = findElement(locator);
            List<WebElement> elementList = new ArrayList<>();
            elementList.add(element);
            wait.until(ExpectedConditions.visibilityOfAllElements(elementList));
            check = false;
        } catch (Throwable e) {
            logger.info("Waiting for select element {} to be visible", locator);
        }
    }
    Select select = new Select(element);
    select.selectByValue(value);
    return element;
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ArrayList(java.util.ArrayList) Select(org.openqa.selenium.support.ui.Select) WebElement(org.openqa.selenium.WebElement) Point(org.openqa.selenium.Point)

Aggregations

WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)527 WebElement (org.openqa.selenium.WebElement)166 WebDriver (org.openqa.selenium.WebDriver)131 Test (org.junit.Test)86 By (org.openqa.selenium.By)54 Actions (org.openqa.selenium.interactions.Actions)53 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)43 TimeoutException (org.openqa.selenium.TimeoutException)38 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)36 IOException (java.io.IOException)28 List (java.util.List)26 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)16 NoSuchElementException (org.openqa.selenium.NoSuchElementException)16