Search in sources :

Example 16 with TimeoutException

use of org.openqa.selenium.TimeoutException 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 17 with TimeoutException

use of org.openqa.selenium.TimeoutException 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 18 with TimeoutException

use of org.openqa.selenium.TimeoutException 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 19 with TimeoutException

use of org.openqa.selenium.TimeoutException in project cerberus-source by cerberustesting.

the class WebDriverService method doSeleniumActionMouseDown.

@Override
public MessageEvent doSeleniumActionMouseDown(Session session, Identifier identifier) {
    MessageEvent message;
    try {
        AnswerItem answer = this.getSeleniumElement(session, identifier, true, true);
        if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
            WebElement webElement = (WebElement) answer.getItem();
            if (webElement != null) {
                Actions actions = new Actions(session.getDriver());
                actions.clickAndHold(webElement);
                actions.build().perform();
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_MOUSEDOWN);
                message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
                return message;
            }
        }
        return answer.getResultMessage();
    } catch (NoSuchElementException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEDOWN_NO_SUCH_ELEMENT);
        message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
        LOG.debug(exception.toString());
        return message;
    } catch (TimeoutException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TIMEOUT);
        message.setDescription(message.getDescription().replace("%TIMEOUT%", String.valueOf(session.getCerberus_selenium_wait_element())));
        LOG.warn(exception.toString());
        return message;
    } catch (WebDriverException exception) {
        LOG.warn(exception.toString());
        return parseWebDriverException(exception);
    }
}
Also used : Actions(org.openqa.selenium.interactions.Actions) MessageEvent(org.cerberus.engine.entity.MessageEvent) WebElement(org.openqa.selenium.WebElement) AnswerItem(org.cerberus.util.answer.AnswerItem) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException) WebDriverException(org.openqa.selenium.WebDriverException)

Example 20 with TimeoutException

use of org.openqa.selenium.TimeoutException in project cerberus-source by cerberustesting.

the class WebDriverService method doSeleniumActionSelect.

@Override
public MessageEvent doSeleniumActionSelect(Session session, Identifier object, Identifier property) {
    MessageEvent message;
    try {
        Select select;
        try {
            AnswerItem answer = this.getSeleniumElement(session, object, true, true);
            if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
                WebElement webElement = (WebElement) answer.getItem();
                if (webElement != null) {
                    select = new Select(webElement);
                    this.selectRequestedOption(select, property, object.getIdentifier() + "=" + object.getLocator());
                    message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SELECT);
                    message.setDescription(message.getDescription().replace("%ELEMENT%", object.getIdentifier() + "=" + object.getLocator()));
                    message.setDescription(message.getDescription().replace("%DATA%", property.getIdentifier() + "=" + property.getLocator()));
                    return message;
                }
            }
            return answer.getResultMessage();
        } catch (NoSuchElementException exception) {
            message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELECT_NO_SUCH_ELEMENT);
            message.setDescription(message.getDescription().replace("%ELEMENT%", object.getIdentifier() + "=" + object.getLocator()));
            LOG.debug(exception.toString());
            return message;
        } catch (TimeoutException exception) {
            message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TIMEOUT);
            message.setDescription(message.getDescription().replace("%TIMEOUT%", String.valueOf(session.getCerberus_selenium_wait_element())));
            LOG.warn(exception.toString());
            return message;
        }
    } catch (CerberusEventException ex) {
        LOG.warn(ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Select(org.openqa.selenium.support.ui.Select) WebElement(org.openqa.selenium.WebElement) AnswerItem(org.cerberus.util.answer.AnswerItem) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Aggregations

TimeoutException (org.openqa.selenium.TimeoutException)238 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)101 WebElement (org.openqa.selenium.WebElement)82 NoSuchElementException (org.openqa.selenium.NoSuchElementException)49 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)40 WebDriver (org.openqa.selenium.WebDriver)39 WebDriverException (org.openqa.selenium.WebDriverException)38 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)31 MessageEvent (org.cerberus.engine.entity.MessageEvent)27 ExpectedConditions (org.openqa.selenium.support.ui.ExpectedConditions)27 Reporter (com.coveros.selenified.utilities.Reporter)26 Test (org.junit.Test)24 By (org.openqa.selenium.By)22 Test (org.testng.annotations.Test)20 Element (com.coveros.selenified.element.Element)17 AnswerItem (org.cerberus.util.answer.AnswerItem)17 IOException (java.io.IOException)16 Dimension (org.openqa.selenium.Dimension)14 Point (org.openqa.selenium.Point)14 Constants (com.coveros.selenified.utilities.Constants)13