Search in sources :

Example 61 with AutomatorException

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

the class ScrollInsideElementToTopAction method execute.

@Override
public void execute() throws Exception {
    findElement();
    try {
        WebElement webElement = getElement();
        JavascriptExecutor js = (JavascriptExecutor) getDriver();
        js.executeScript("arguments[0].scrollTo(0,0);", webElement);
    } catch (Exception e) {
        log.error("unable to scroll inside an element", e);
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue()));
    }
    setSuccessMessage(SUCCESS_MESSAGE);
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebElement(org.openqa.selenium.WebElement) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 62 with AutomatorException

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

the class RestAPIRunTimeDataProcessor method updateRequestUrlRuntimeValues.

private void updateRequestUrlRuntimeValues() throws AutomatorException {
    log.debug("Updating runtime variables in URL, RestStep ID:" + restfulStepEntity.getId());
    try {
        String updatedURL = replaceRuntimeVariables(restfulStepEntity.getUrl());
        restfulStepEntity.setUrl(updatedURL.trim());
    } catch (AutomatorException e) {
        throw new AutomatorException("Error while replacing runtime variables in request URL." + e.getMessage());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 63 with AutomatorException

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

the class RestAPIRunTimeDataProcessor method updateExpectedStatusRuntimeVariables.

private void updateExpectedStatusRuntimeVariables() throws AutomatorException {
    log.debug("Updating Run time data in Status, RestStep ID:" + restfulStepEntity.getId());
    try {
        String updatedExpectedStatus = replaceRuntimeVariables(restfulStepEntity.getStatus());
        restfulStepEntity.setStatus(updatedExpectedStatus);
    } catch (AutomatorException e) {
        throw new AutomatorException("Error while replacing runtime variables in Verify Response Status." + e.getMessage());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 64 with AutomatorException

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

the class RestAPIRunTimeDataProcessor method updateExpectedBodyRuntimeVariables.

private void updateExpectedBodyRuntimeVariables() throws AutomatorException {
    log.debug("Updating runtime data in expected body,RestStep ID:" + restfulStepEntity.getId());
    try {
        String updatedExpectedResponse = replaceRuntimeVariables(restfulStepEntity.getResponse());
        restfulStepEntity.setResponse(updatedExpectedResponse);
    } catch (AutomatorException e) {
        throw new AutomatorException("Error while replacing runtime variables in Verify Response body." + e.getMessage());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 65 with AutomatorException

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

the class RestAPIRunTimeDataProcessor method replaceRuntimeVariables.

private String replaceRuntimeVariables(String inputData) throws AutomatorException {
    log.debug("Replacing runtime parameters in :" + inputData);
    String updatedData = inputData;
    String[] names = StringUtils.substringsBetween(inputData, NaturalTextActionConstants.restDataiRunStartPattern, NaturalTextActionConstants.restDataiRunaEndPattern);
    if (names == null) {
        return inputData;
    }
    for (String runTimeVarName : names) {
        String runTimeValue = new RuntimeDataProvider().getRuntimeData(runTimeVarName);
        if (runTimeValue == null) {
            throw new AutomatorException(String.format(MSG_RUN_TIME_VARIABLE_NOT_SET, runTimeVarName));
        }
        String runTimeVarPattern = String.format("%s%s%s", NaturalTextActionConstants.restDataRunStartPattern, Pattern.quote(runTimeVarName), NaturalTextActionConstants.restDatRunaEndPattern);
        updatedData = updatedData.replaceAll(runTimeVarPattern, Matcher.quoteReplacement(runTimeValue));
        log.debug(String.format("Replaced runtime var:%s with %s", runTimeVarName, runTimeValue));
    }
    return updatedData;
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) RuntimeDataProvider(com.testsigma.automator.utilities.RuntimeDataProvider)

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