Search in sources :

Example 16 with AutomatorException

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

the class ElementAction method setElementSearchCriteria.

protected void setElementSearchCriteria(String elementActionVariableName) throws AutomatorException {
    log.debug("Setting element search criteria");
    ElementPropertiesEntity elementPropertiesEntity = getElementPropertiesEntity(elementActionVariableName);
    if (StringUtils.isBlank(elementPropertiesEntity.getLocatorValue())) {
        throw new AutomatorException(String.format(LOCATOR_VALUE_MISSING_ERROR_MSG, elementPropertiesEntity.getFindByType()));
    }
    elementSearchCriteria = new ElementSearchCriteria(elementPropertiesEntity.getFindByType(), elementPropertiesEntity.getLocatorValue());
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) ElementPropertiesEntity(com.testsigma.automator.entity.ElementPropertiesEntity)

Example 17 with AutomatorException

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

the class MobileDriver method createDriver.

@Override
protected RemoteWebDriver createDriver(DesiredCapabilities desiredCapabilities) throws AutomatorException {
    try {
        Calendar startTime = Calendar.getInstance();
        createDriverInstance(desiredCapabilities);
        log.info("Stating with post mobile driver creation actions");
        Calendar endTime = Calendar.getInstance();
        log.info("Web Driver Session Created in - " + (endTime.getTimeInMillis() - startTime.getTimeInMillis()));
        setTimeouts();
        return remoteWebDriver;
    } catch (Exception e) {
        if (e.getCause() instanceof SSLException || e.getCause() instanceof ConnectException) {
            throw new AutomatorException(e.getCause() + String.format(APPIUM_INVALID_URL));
        } else {
            throw new AutomatorException(e.getMessage(), e);
        }
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Calendar(java.util.Calendar) SSLException(javax.net.ssl.SSLException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) MalformedURLException(java.net.MalformedURLException) SSLException(javax.net.ssl.SSLException) ConnectException(java.net.ConnectException) ConnectException(java.net.ConnectException)

Example 18 with AutomatorException

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

the class SafariDriver method setTimeouts.

@Override
public void setTimeouts() throws AutomatorException {
    String osVersion = getPlatform();
    int browserVersionValue = Integer.parseInt(getSafariVersion().split("\\.")[0]);
    if (((osVersion.equals("macOS 10.13") || osVersion.equals("macOS 10.14") || osVersion.equals("High Sierra")) || (osVersion.equals("macOS 10.15") || osVersion.equals("Catalina"))) && (browserVersionValue >= 12) && (executionLabType != ExecutionLabType.Hybrid)) {
        SessionId session = remoteWebDriver.getSessionId();
        Map<String, Object> timeouts = new HashMap<>();
        timeouts.put("implicit", settings.getElementTimeout() * 1000);
        timeouts.put("pageLoad", settings.getPageLoadTimeout() * 1000);
        try {
            UriComponents uriComponents = UriComponentsBuilder.fromUriString("/session/{sessionId}/timeouts").build().expand(session.toString()).encode();
            String url = webDriverSettings.getWebDriverServerUrl() + uriComponents.toUriString();
            HttpClient httpClient = EnvironmentRunner.getWebAppHttpClient();
            String authHeader = HttpClient.BEARER + " " + getSettings().getJwtApiKey();
            HttpResponse<String> response = null;
            for (int i = 0; i < 3; i++) {
                try {
                    response = httpClient.post(url, timeouts, new TypeReference<>() {
                    }, authHeader);
                    break;
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }
            }
            log.error(response.getStatusCode() + " - " + response.getResponseText());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new AutomatorException(e.getMessage(), e);
        }
    } else {
        super.setTimeouts();
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) UriComponents(org.springframework.web.util.UriComponents) HashMap(java.util.HashMap) HttpClient(com.testsigma.automator.http.HttpClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) SessionId(org.openqa.selenium.remote.SessionId) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) MalformedURLException(java.net.MalformedURLException)

Example 19 with AutomatorException

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

the class WebDriver method setLocation.

protected void setLocation() throws AutomatorException {
    if (locationCapability != null) {
        try {
            String[] coordinates = locationCapability.getCapabilityValue().toString().split(",");
            ((LocationContext) new Augmenter().augment(getRemoteWebDriver())).setLocation(new Location(Double.parseDouble(coordinates[0]), Double.parseDouble(coordinates[1]), Double.parseDouble(coordinates[2])));
        } catch (NumberFormatException e) {
            throw new AutomatorException(INVALID_GEO_LOCATION_ERROR);
        }
    }
}
Also used : Augmenter(org.openqa.selenium.remote.Augmenter) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) LocationContext(org.openqa.selenium.html5.LocationContext) Location(org.openqa.selenium.html5.Location)

Example 20 with AutomatorException

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

the class DriverManager method storeTestSuiteSessionId.

private void storeTestSuiteSessionId(Long entityId) throws AutomatorException {
    try {
        TestSuiteResultRequest testSuiteResultRequest = new TestSuiteResultRequest();
        testSuiteResultRequest.setId(entityId);
        testSuiteResultRequest.setSessionId(getSessionId());
        AutomatorConfig.getInstance().getAppBridge().updateTestSuiteResultData(testSuiteResultRequest);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new AutomatorException(e.getMessage(), e);
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) IOException(java.io.IOException)

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