Search in sources :

Example 6 with BFElementNotFoundException

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

the class JsoupHelper method getElements.

private static List<WebElement> getElements(String text, List<String> selectors) {
    if (selectors.isEmpty()) {
        throw new BFElementNotFoundException("Element with text [" + text + "] not found.");
    }
    List<WebElement> elementsToReturn = new ArrayList<WebElement>();
    for (String selector : selectors) {
        By elementSelector = By.cssSelector(selector);
        WebElement foundElement = BasePage.getDriver().findElement(elementSelector);
        elementsToReturn.add(foundElement);
    }
    return elementsToReturn;
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) By(org.openqa.selenium.By) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement)

Example 7 with BFElementNotFoundException

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

the class ElementPositionUtils method isElementsPositionRelatedX.

/**
 * Method checks if second element is in given relation to first element considering X coordinate
 *
 * @param selectorFirst
 *            By object with an selector
 * @param selectorSecond
 *            By object with an selector
 * @param scope
 *            WebElement which contains comparing objects
 * @param position
 *            relation of a second element to first one
 * @return true if two elements are placed in given relation
 * @throws BFElementNotFoundException
 *             if elements do not exist
 */
public static boolean isElementsPositionRelatedX(By selectorFirst, By selectorSecond, WebElement scope, RelatedPositionEnum position) {
    WebElement elementFirst = BasePage.getDriver().findElementQuietly(scope, selectorFirst);
    WebElement elementSecond = BasePage.getDriver().findElementQuietly(scope, selectorSecond);
    if (elementFirst == null) {
        throw new BFElementNotFoundException(selectorFirst);
    }
    if (elementSecond == null) {
        throw new BFElementNotFoundException(selectorSecond);
    }
    return ElementPositionUtils.isElementsPositionRelatedX(elementFirst, elementSecond, position);
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement)

Example 8 with BFElementNotFoundException

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

the class NewFirefoxDriver 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 9 with BFElementNotFoundException

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

the class NewInternetExplorerDriver 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 10 with BFElementNotFoundException

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

the class DriverExtention method waitForElement.

public WebElement waitForElement(final By by) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebElement element = null;
    try {
        element = webDriverWait().until(new ExpectedCondition<WebElement>() {

            @Override
            public WebElement apply(WebDriver driver) {
                return driver.findElement(by);
            }
        });
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(by, isTimeout, BasePage.EXPLICITYWAITTIMER);
    }
    BFLogger.logTime(startTime, "waitForElement()", by.toString());
    return element;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) 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