use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class WaitUntilTextIsAbsentAction method execute.
@Override
protected void execute() throws Exception {
try {
boolean textNotPresent = getWebDriverWait().until(ExpectedConditions.not(CustomExpectedConditions.mobileTextToBePresent(getTestData())));
Assert.isTrue(textNotPresent, String.format(FAILURE_MESSAGE, getTimeout(), getTestData()));
setSuccessMessage(SUCCESS_MESSAGE);
} catch (TimeoutException e) {
throw new AutomatorException(String.format(FAILURE_MESSAGE, getTimeout(), getTestData()), (Exception) e.getCause());
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class TestsuiteRunner method getTestCase.
private TestCaseEntity getTestCase(TestCaseEntity testCaseEntity, int maxTries) throws AutomatorException {
try {
TestCaseEntity testCaseEntityCopy = testCaseEntity;
testCaseEntity = AutomatorConfig.getInstance().getAppBridge().getTestCase(environmentRunResult.getId(), testCaseEntity);
if (testCaseEntity != null) {
if (ResultConstant.STOPPED == testCaseEntity.getResult()) {
ExecutionEnvironmentRunner.setStoppedStatus();
}
}
if ((testCaseEntity.getErrorCode() != null) && maxTries > 0) {
RemoteWebDriver remoteWebDriver = DriverManager.getDriverManager().getDriver().getRemoteWebDriver();
remoteWebDriver.getWindowHandle();
Thread.sleep(this.testCaseFetchWaitInterval);
return getTestCase(testCaseEntityCopy, maxTries - 1);
}
return testCaseEntity;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new AutomatorException(ErrorCodes.TEST_CASE_DETAILS_FETCH_FAILED, AutomatorMessages.FAILED_TO_FETCH_TEST_CASE_DETAILS + " - " + e.getMessage());
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class TestsuiteRunner method runSuite.
private void runSuite(TestSuiteEntity testSuiteEntity, TestSuiteResult testSuiteResult) throws AutomatorException {
resetThreadContextData();
populateThreadContextData(testSuiteEntity, testSuiteResult);
log.debug("Running test suite - " + testSuiteEntity.getName());
if (!testDeviceEntity.getCreateSessionAtCaseLevel()) {
restartCurrentSession(testSuiteResult);
}
List<TestCaseEntity> testCaseEntityList = testSuiteEntity.getTestCases();
List<TestCaseResult> testCasesResult = new ArrayList<>();
testSuiteResult.setTestCaseResults(testCasesResult);
testSuiteResult.setResult(ResultConstant.SUCCESS);
boolean executionStarted = false;
for (TestCaseEntity testCaseEntity : testCaseEntityList) {
boolean testCaseRunFailed = false;
boolean testCasePrerequisiteFailed = false;
TestCaseResult testCaseResult = new TestCaseResult(testCaseEntity.getId());
try {
testCaseResult.setId(testCaseEntity.getTestCaseResultId());
testCaseResult.setEnvRunId(testSuiteEntity.getEnvironmentResultId());
testCaseResult.setGroupResultId(testSuiteEntity.getResultId());
testCaseResult.setGroupId(testSuiteEntity.getId());
testCaseResult.setTestCaseId(testCaseEntity.getId());
testCaseResult.setTestDataSetName(testCaseEntity.getTestDataSetName());
testCaseResult.setTestDataId(testCaseEntity.getTestDataId());
testCaseResult.setIsStepGroup(testCaseEntity.getIsStepGroup());
testCaseResult.setDataDriven(testCaseEntity.getIsDataDriven());
testCaseResult.setStartTime(new Timestamp(System.currentTimeMillis()));
testCasesResult.add(testCaseResult);
testCaseResult.setVisualTestingEnabled(testPlanRunSettingEntity.isVisualTestingEnabled());
testcaseResultMap.put(testCaseEntity.getId(), testCaseResult);
if (skipExecution) {
testCaseResult.setMessage(resultFailureMessage);
} else if (hasPreRequisite(testCaseEntity)) {
testCasePrerequisiteFailed = checkTestCasePrerequisiteFailure(testCaseEntity, testCaseResult);
}
try {
if (!testCaseEntity.getIsDataDriven()) {
testCaseEntity = getTestCase(testCaseEntity, this.testCaseFetchMaxTries);
new ErrorUtil().checkError(testCaseEntity.getErrorCode(), testCaseEntity.getMessage());
}
} catch (AutomatorException e) {
log.error(e.getMessage(), e);
testCaseRunFailed = true;
resultFailureMessage = e.getMessage();
testCaseResult.setResult(ResultConstant.FAILURE);
testCaseResult.setMessage(resultFailureMessage);
}
if (!testCaseRunFailed) {
if (ExecutionEnvironmentRunner.isRunning()) {
testSuiteResult.setSessionCreatedOn(new Timestamp(System.currentTimeMillis()));
if (testCaseEntity.getIsDataDriven()) {
runDataDrivenTestCase(testCaseEntity, testCaseResult, false, testCasePrerequisiteFailed);
} else {
new TestcaseRunner(testCaseEntity, testCaseResult, mapStepResult, skipExecution || testCasePrerequisiteFailed, resultFailureMessage).run();
}
executionStarted = true;
} else {
testCaseResult.setResult(ResultConstant.STOPPED);
testCaseResult.setMessage(AutomatorMessages.MSG_USER_ABORTED_EXECUTION);
testCaseResult.setEndTime(new Timestamp(System.currentTimeMillis()));
postTestcaseResult(testCaseResult);
break;
}
}
testCaseResult.setEndTime(new Timestamp(System.currentTimeMillis()));
postTestcaseResult(testCaseResult);
} catch (Exception ex) {
log.error("Unhandled exception while processing test case");
log.error(ex.getMessage(), ex);
testCaseResult.setResult(ResultConstant.ABORTED);
testCaseResult.setMessage(ex.getMessage());
try {
postTestcaseResult(testCaseResult);
} catch (Exception e) {
log.error("Unhandled exception while posting test case results");
log.error(e.getMessage(), e);
}
}
if (testCaseResult.getResult().getId() > testSuiteResult.getResult().getId()) {
testSuiteResult.setResult(testCaseResult.getResult());
}
}
testSuiteResult.setSessionCompletedOn(new Timestamp(System.currentTimeMillis()));
testSuiteResult.setEndTime(new Timestamp(System.currentTimeMillis()));
if (testSuiteResult.getResult() == ResultConstant.SUCCESS) {
testSuiteResult.setMessage(AutomatorMessages.MSG_GROUP_SUCCESS);
} else if (StringUtils.isBlank(testSuiteResult.getMessage())) {
testSuiteResult.setMessage(AutomatorMessages.MSG_GROUP_FAILED);
}
resetThreadContextData();
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class WebTestcaseStepRunner method execute.
protected void execute(Map<String, String> envSettings, TestCaseStepResult testCaseStepResult, TestCaseStepEntity testcaseStep, TestCaseResult testCaseResult) throws AutomatorException {
this.settings = EnvironmentRunner.getRunnerEnvironmentEntity().getTestPlanSettings();
this.testcaseStep = testcaseStep;
this.testCaseResult = testCaseResult;
this.envSettings = envSettings;
this.testCaseStepResult = testCaseStepResult;
runtimeDataProvider = new RuntimeDataProvider();
setInitialElementData();
try {
updateRuntimeValueInElement();
updateRuntimeValueInTestData();
} catch (Exception e) {
log.error(e.getMessage(), e);
this.testCaseStepResult.setResult(ResultConstant.FAILURE);
this.testCaseStepResult.setMessage(e.getMessage());
return;
}
execute();
if (isAutomatorException() && settings.getHasSuggestionFeature() && testcaseStep.getAddonNaturalTextActionEntity() == null) {
diagnoseStepFailure();
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class DriverManager method startSession.
public void startSession(DriverSessionType driverSessionType, Long entityId, Boolean isRestart) throws AutomatorException {
RemoteWebDriver remoteWebDriver;
beforeSessionCreateActions();
try {
remoteWebDriver = createDriverSession();
storeSessionId(driverSessionType, entityId);
this.isRestart = isRestart;
if (!isRestart) {
this.initialSessionId = getSessionId();
log.info("Initial Session ID:" + this.initialSessionId);
} else {
this.restartSessionId = getSessionId();
log.info("Restarted Session ID:" + this.restartSessionId);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
String errorMessage = parseErrorMessage(e.getMessage());
if (StringUtils.isBlank(errorMessage)) {
errorMessage = AutomatorMessages.EXCEPTION_WEBDRIVER_NOTCREATED + " - " + e.getMessage();
} else {
errorMessage = "Unable to create a new Test Session due to unexpected failure(0x537). " + errorMessage;
}
endSession();
throw new AutomatorException(ErrorCodes.DRIVER_NOT_CREATED, errorMessage);
}
if (remoteWebDriver != null) {
log.info("Driver Session ID - " + getSessionId());
} else {
throw new AutomatorException(ErrorCodes.DRIVER_NOT_CREATED, AutomatorMessages.EXCEPTION_WEBDRIVER_NOTCREATED);
}
afterSessionCreateActions();
}
Aggregations