Search in sources :

Example 46 with AutomatorException

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

the class TestsuiteRunner method runSuites.

public EnvironmentRunResult runSuites(List<TestSuiteEntity> testCaseGroupEntities) throws AutomatorException {
    log.debug("----- Running Test Suites For Environment Run Result [" + environmentRunResult.getId() + "] -----");
    List<TestSuiteResult> testCaseGroupsResults = new ArrayList<TestSuiteResult>();
    environmentRunResult.setGroupResults(testCaseGroupsResults);
    ResultConstant result = ResultConstant.SUCCESS;
    for (TestSuiteEntity testSuiteEntity : testCaseGroupEntities) {
        skipExecution = false;
        resultFailureMessage = null;
        TestSuiteResult testSuiteResult = new TestSuiteResult();
        testSuiteResult.setId(testSuiteEntity.getResultId());
        testSuiteResult.setGroupId(testSuiteEntity.getId());
        testSuiteResult.setEnvRunId(testSuiteEntity.getEnvironmentResultId());
        testSuiteResult.setExecutionInitiatedOn(environmentRunResult.getExecutionInitiatedOn());
        testSuiteResult.setAgentPickedOn(environmentRunResult.getAgentPickedOn());
        testSuiteResult.setDeviceAllocatedOn(environmentRunResult.getDeviceAllocatedOn());
        testCaseGroupsResults.add(testSuiteResult);
        groupResultMap.put(testSuiteEntity.getId(), testSuiteResult);
        testSuiteResult.setStartTime(new Timestamp(System.currentTimeMillis()));
        try {
            log.debug("Running Test Suite -  " + testSuiteEntity);
            try {
                checkSuitePrerequisiteFailure(testSuiteEntity, testSuiteResult);
                if (ExecutionEnvironmentRunner.isRunning()) {
                    log.debug("Execution environment status is running...Proceeding with the test suite execution....");
                    runSuite(testSuiteEntity, testSuiteResult);
                } else {
                    log.debug("Execution environment status is stopped...stopping test suite execution....");
                    testSuiteResult.setResult(ResultConstant.STOPPED);
                    testSuiteResult.setMessage(AutomatorMessages.MSG_USER_ABORTED_EXECUTION);
                    testSuiteResult.setEndTime(new Timestamp(System.currentTimeMillis()));
                    postSuiteResult(testSuiteResult);
                    break;
                }
            } catch (Exception ex) {
                log.error(ex.getMessage(), ex);
                testSuiteResult.setResult(ResultConstant.FAILURE);
                testSuiteResult.setMessage(ex.getMessage());
            }
            testSuiteResult.setEndTime(new Timestamp(System.currentTimeMillis()));
            postSuiteResult(testSuiteResult);
        } catch (Exception ex) {
            log.error("Unhandled exception while processing test suite");
            log.error(ex.getMessage(), ex);
            testSuiteResult.setEndTime(new Timestamp(System.currentTimeMillis()));
            testSuiteResult.setResult(ResultConstant.FAILURE);
            testSuiteResult.setMessage(ex.getMessage());
            try {
                postSuiteResult(testSuiteResult);
            } catch (Exception e) {
                log.error("Unhandled exception while sending test suite results");
                log.error(e.getMessage(), e);
            }
        }
        if (testSuiteResult.getResult().getId() > result.getId()) {
            result = testSuiteResult.getResult();
        }
    }
    if (environmentRunResult.getResult() == null) {
        environmentRunResult.setResult(result);
    }
    return environmentRunResult;
}
Also used : ArrayList(java.util.ArrayList) Timestamp(java.sql.Timestamp) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 47 with AutomatorException

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

the class AppInstaller method installApp.

public String installApp(String deviceName, String deviceUniqueId, String appUrl) throws AutomatorException {
    File appFile = null;
    log.info(String.format("Install app %s on device %s", appUrl, deviceName));
    try {
        appFile = downloadApp(appUrl);
        String bundleId = getAppBundleId(appFile);
        Process p = iosDeviceCommandExecutor.runDeviceCommand(new String[] { "-u", deviceUniqueId, "install", appFile.getAbsolutePath() });
        p.waitFor(60, TimeUnit.SECONDS);
        String installOutput = iosDeviceCommandExecutor.getProcessStreamResponse(p);
        log.info(installOutput);
        boolean installed = checkIfInstalled(deviceName, deviceUniqueId, bundleId);
        if (installed) {
            return bundleId;
        } else {
            throw new AutomatorException("App not installed on device", "App not installed on device");
        }
    } catch (Exception e) {
        throw new AutomatorException(e.getMessage(), e);
    } finally {
        if ((appFile != null) && appFile.exists()) {
            boolean deleted = appFile.delete();
            if (!deleted) {
                log.error("Unable to delete temp app file - " + appFile.getAbsolutePath());
            }
        }
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) File(java.io.File) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 48 with AutomatorException

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

the class IosDeviceCommandExecutor method runDeviceCommand.

public Process runDeviceCommand(String[] subCommand) throws AutomatorException {
    try {
        String[] command = ArrayUtils.addAll(new String[] { getIosIdeviceExecutablePath() }, subCommand);
        log.debug("Running a idevice command - " + Arrays.toString(command));
        ProcessBuilder processBuilder = new ProcessBuilder(command);
        return processBuilder.start();
    } catch (Exception e) {
        throw new AutomatorException(e.getMessage());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 49 with AutomatorException

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

the class ExecutionEnvironmentRunner method checkForEmptyEnvironment.

public void checkForEmptyEnvironment() throws AutomatorException {
    boolean isEmpty = true;
    for (TestSuiteEntity entity : testDeviceEntity.getTestSuites()) {
        if (entity.getTestCases().size() > 0) {
            isEmpty = false;
            break;
        }
    }
    if (isEmpty) {
        AutomatorException ex = new AutomatorException(AutomatorMessages.NO_TESTCASES_AVAILABLE, AutomatorMessages.NO_TESTCASES_AVAILABLE);
        ex.setDispMessage(AutomatorMessages.NO_TESTCASES_AVAILABLE);
        throw ex;
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TestSuiteEntity(com.testsigma.automator.entity.TestSuiteEntity)

Example 50 with AutomatorException

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

the class StandaloneAppBridge method updateRunTimeData.

@Override
public void updateRunTimeData(Long environmentResultId, RuntimeEntity runtimeEntity) throws AutomatorException {
    try {
        RuntimeRequest runtimeRequest = convertToObject(runtimeEntity, RuntimeRequest.class);
        runTimeDataService.updateRunTimeData(environmentResultId, runtimeRequest);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new AutomatorException(e.getMessage(), e);
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) RuntimeRequest(com.testsigma.web.request.RuntimeRequest) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

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