Search in sources :

Example 11 with BFElementNotFoundException

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

the class DriverExtention method waitForPageLoaded.

public void waitForPageLoaded() throws BFElementNotFoundException {
    long startTime = System.currentTimeMillis();
    final String jsVariable = "return document.readyState";
    ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() {

        public Boolean apply(WebDriver driver) {
            return ((JavascriptExecutor) driver).executeScript(jsVariable).equals("complete");
        }
    };
    int progressBarWaitTimer = BasePage.PROGRESSBARWAITTIMER;
    WebDriverWait wait = webDriverWait(progressBarWaitTimer);
    try {
        wait.until(expectation);
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(By.cssSelector(jsVariable), isTimeout, progressBarWaitTimer);
    }
    BFLogger.logTime(startTime, "waitForPageLoaded");
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 12 with BFElementNotFoundException

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

the class NewChromeDriver method findElement.

/**
 * @deprecated As of release 1.0.0, replaced by {@link #findElementDynamic(By)()}
 */
@Deprecated
@Override
public WebElement findElement(By by) throws BFElementNotFoundException {
    BaseTest.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)

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