Search in sources :

Example 36 with TimeoutException

use of org.openqa.selenium.TimeoutException in project testsigma by testsigmahq.

the class CurrentWebPageLoadingStatusAction method execute.

@Override
public void execute() throws Exception {
    String status = getTestData();
    switch(status) {
        case ActionConstants.LOADED:
            try {
                boolean pageLoaded = getWebDriverWait().until(CustomExpectedConditions.waitForPageLoadUsingJS());
                Assert.isTrue(pageLoaded, LOADED_FAILURE_MESSAGE);
                setSuccessMessage(LOADED_SUCCESS_MESSAGE);
                break;
            } catch (TimeoutException e) {
                throw new AutomatorException(LOADED_FAILURE_MESSAGE, (Exception) e.getCause());
            }
        case ActionConstants.NOT_LOADED:
            try {
                boolean pageLoaded = getWebDriverWait().until(CustomExpectedConditions.waitForPageLoadUsingJS());
                Assert.isTrue(!pageLoaded, NOT_LOADED_ERROR_MESSAGE);
                setSuccessMessage(NOT_LOADED_SUCCESS_MESSAGE);
                break;
            } catch (TimeoutException e) {
                throw new AutomatorException(NOT_LOADED_ERROR_MESSAGE, (Exception) e.getCause());
            }
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 37 with TimeoutException

use of org.openqa.selenium.TimeoutException in project testsigma by testsigmahq.

the class WaitUntilFileDownloadIsCompleteAction method execute.

@Override
public void execute() throws Exception {
    getDriver().navigate().to("chrome://downloads");
    try {
        String chromeJavaScript = "var tag = document.querySelector('downloads-manager').shadowRoot;" + "    var item_tags = tag.querySelectorAll('downloads-item');" + "    var item_tags_length = item_tags.length;" + "    var progress_lst = [];" + "    for(var i=0; i<item_tags_length; i++) {" + "        var intag = item_tags[i].shadowRoot;" + "        var progress_tag = intag.getElementById('progress');" + "        var progress = null;" + "        if(progress_tag && progress_tag.value < 100) {" + "             progress = progress_tag.value;" + "        }" + "        if(progress!=null) progress_lst.push(progress);" + "    }" + "    return progress_lst";
        // We create a custom wait with long sleep time. Since we are only allowing max of 120 secs for step level timeout(which
        // may not be sufficient for some downloads), we will be giving additional timeout here.
        WebDriverWait waiter = new WebDriverWait(getDriver(), 600, 5000);
        boolean isDownloadComplted = waiter.until(CustomExpectedConditions.downloadToBeCompletedInChrome(chromeJavaScript));
        Assert.isTrue(isDownloadComplted, String.format(FAILURE_MESSAGE, 600));
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (TimeoutException e) {
        throw new AutomatorException(String.format(FAILURE_MESSAGE, 600), (Exception) e.getCause());
    } finally {
        getDriver().navigate().back();
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 38 with TimeoutException

use of org.openqa.selenium.TimeoutException in project testsigma by testsigmahq.

the class WaitUntilElementHasValueAction method execute.

@Override
protected void execute() throws Exception {
    try {
        boolean valueMatching = getWebDriverWait().until(ExpectedConditions.textToBePresentInElementValue(getBy(), getTestData()));
        Assert.isTrue(valueMatching, String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout(), getTestData()));
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (TimeoutException e) {
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout(), getTestData()), (Exception) e.getCause());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 39 with TimeoutException

use of org.openqa.selenium.TimeoutException in project testsigma by testsigmahq.

the class WaitUntilElementIsClickableAction method execute.

@Override
public void execute() throws Exception {
    try {
        WebElement visibleElement = getWebDriverWait().until(ExpectedConditions.elementToBeClickable(getBy()));
        Assert.notNull(visibleElement, String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout()));
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (TimeoutException e) {
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout()), (Exception) e.getCause());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) WebElement(org.openqa.selenium.WebElement) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 40 with TimeoutException

use of org.openqa.selenium.TimeoutException in project testsigma by testsigmahq.

the class WaitUntilElementIsDisabledAction method execute.

@Override
public void execute() throws Exception {
    try {
        boolean elementDisabled = getWebDriverWait().until(CustomExpectedConditions.elementIsDisabled(getBy()));
        Assert.isTrue(elementDisabled, String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout()));
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (TimeoutException e) {
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout()), (Exception) e.getCause());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException)

Aggregations

TimeoutException (org.openqa.selenium.TimeoutException)247 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)109 WebElement (org.openqa.selenium.WebElement)85 NoSuchElementException (org.openqa.selenium.NoSuchElementException)52 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)40 WebDriver (org.openqa.selenium.WebDriver)39 WebDriverException (org.openqa.selenium.WebDriverException)39 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)25 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