Search in sources :

Example 11 with BFElementNotFoundException

use of com.capgemini.mrchecker.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((Function<? super WebDriver, WebElement>) 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 : WebDriver(org.openqa.selenium.WebDriver) Function(java.util.function.Function) BFElementNotFoundException(com.capgemini.mrchecker.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 12 with BFElementNotFoundException

use of com.capgemini.mrchecker.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.mrchecker.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Aggregations

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