Search in sources :

Example 21 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.

the class DriverManager method endSession.

public void endSession() throws AutomatorException {
    try {
        if (getDriver() != null && (getDriver().getRemoteWebDriver() != null)) {
            log.info("Ending session(if exists) with execution UUID - " + executionUuid + " and session ID - " + getSessionId());
            RemoteWebDriver driver = getDriver().getRemoteWebDriver();
            try {
                beforeEndSessionActions();
                driver.quit();
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                driver.quit();
            }
            afterEndSessionActions();
        } else {
            log.debug("There is no driver session with executionID - " + executionUuid);
        }
    } catch (Exception e) {
        throw new AutomatorException(e.getMessage(), e);
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) IOException(java.io.IOException)

Example 22 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.

the class TestsigmaDriver method parseCapabilities.

protected Map<String, Object> parseCapabilities(String cap, String capabilityType) throws AutomatorException {
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> capabilities;
    try {
        capabilities = mapper.readValue(cap, Map.class);
    } catch (IOException e) {
        throw new AutomatorException("Invalid " + capabilityType + " options provided in the desired capabilities configuration.");
    }
    return capabilities;
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) IOException(java.io.IOException) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 23 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException 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 24 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException 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 25 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException 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)

Aggregations

AutomatorException (com.testsigma.automator.exceptions.AutomatorException)119 TimeoutException (org.openqa.selenium.TimeoutException)31 WebElement (org.openqa.selenium.WebElement)19 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)9 Select (org.openqa.selenium.support.ui.Select)6 TestsigmaException (com.testsigma.agent.exception.TestsigmaException)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 RuntimeDataProvider (com.testsigma.automator.utilities.RuntimeDataProvider)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Map (java.util.Map)3 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)3 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)3 PathNotFoundException (com.jayway.jsonpath.PathNotFoundException)2 ElementNotDisplayedException (com.testsigma.automator.actions.exceptions.ElementNotDisplayedException)2 MobileApp (com.testsigma.automator.mobile.MobileApp)2 ObjectMapperService (com.testsigma.automator.service.ObjectMapperService)2 ErrorUtil (com.testsigma.automator.utilities.ErrorUtil)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2