Search in sources :

Example 1 with BFElementNotFoundException

use of com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException in project devonfw-testing by devonfw.

the class NewRemoteWebDriver method findElement.

/**
 * @deprecated As of release 1.0.0, replaced by {@link #findElementDynamic(By)()}
 */
@Deprecated
@Override
public WebElement findElement(By by) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    WebElement elementFromDriver = null;
    try {
        elementFromDriver = super.findElement(by);
    } catch (NoSuchElementException e) {
        throw new BFElementNotFoundException(by);
    }
    return new NewRemoteWebElement(elementFromDriver);
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 2 with BFElementNotFoundException

use of com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException in project devonfw-testing by devonfw.

the class DriverExtention method waitUntilElementIsClickable.

public WebElement waitUntilElementIsClickable(final By by) {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebElement element = null;
    try {
        element = webDriverWait().until(ExpectedConditions.elementToBeClickable(by));
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(by, isTimeout, BasePage.EXPLICITYWAITTIMER);
    }
    BFLogger.logTime(startTime, "waitUntilElementIsClickable()", by.toString());
    return element;
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 3 with BFElementNotFoundException

use of com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException in project devonfw-testing by devonfw.

the class DriverExtention method waitForElementVisible.

public WebElement waitForElementVisible(final By by) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebElement element = null;
    try {
        element = webDriverWait().until(ExpectedConditions.visibilityOfElementLocated(by));
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(by, isTimeout, BasePage.EXPLICITYWAITTIMER);
    }
    BFLogger.logTime(startTime, "waitForElementVisible()", by.toString());
    return element;
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 4 with BFElementNotFoundException

use of com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException 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 5 with BFElementNotFoundException

use of com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException 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)

Aggregations

BFElementNotFoundException (com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException)12 WebElement (org.openqa.selenium.WebElement)11 NoSuchElementException (org.openqa.selenium.NoSuchElementException)9 TimeoutException (org.openqa.selenium.TimeoutException)6 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)3 ArrayList (java.util.ArrayList)2 WebDriver (org.openqa.selenium.WebDriver)2 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)2 By (org.openqa.selenium.By)1