use of com.testsigma.automator.actions.DriverAction in project testsigma by testsigmahq.
the class ClickOnButtonInTheBrowserProxyAction method initializeChildSnippet.
protected Object initializeChildSnippet(Class<?> snippetClassName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
DriverAction snippet = (DriverAction) snippetClassName.getDeclaredConstructor().newInstance();
snippet.setDriver(this.getDriver());
return snippet;
}
use of com.testsigma.automator.actions.DriverAction in project testsigma by testsigmahq.
the class ActionStepExecutor method execute.
public void execute() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, NoSuchMethodException, AutomatorException, ClassNotFoundException, InstantiationException {
Class<?> className = Class.forName(testCaseStepEntity.getSnippetClass());
DriverAction snippet = (DriverAction) className.getDeclaredConstructor().newInstance();
snippet.setDriver(DriverManager.getRemoteWebDriver());
snippet.setTimeout(testCaseStepEntity.getWaitTime().longValue());
snippet.setTestDataPropertiesEntityMap(testCaseStepEntity.getTestDataMap());
snippet.setElementPropertiesEntityMap(testCaseStepEntity.getElementsMap());
snippet.setAttributesMap(testCaseStepEntity.getAttributesMap());
snippet.setGlobalElementTimeOut(testCaseStepResult.getTestPlanRunSettingEntity().getElementTimeOut().longValue());
snippet.setRuntimeDataProvider(prepareRunTimeDataProvider());
snippet.setEnvSettings(envSettings);
snippet.setAdditionalData(testCaseStepEntity.getAdditionalData());
ActionResult snippetResult = snippet.run();
// We retry test step execution on failure based on the exception type.
snippetResult = reTrySnippetIfEligible(snippetResult, snippet, testCaseStepEntity, testCaseStepResult);
testCaseStepResult.getMetadata().setSnippetResultMetadata(snippet.getResultMetadata());
testCaseStepResult.getOutputData().putAll(snippet.getTestDataParams());
if (snippetResult == ActionResult.FAILED) {
log.error("Test case step FAILED....");
NaturalActionException naturalActionException = new NaturalActionException(snippet.getErrorMessage(), snippet.getException(), snippet.getErrorCode().getErrorCode().intValue());
testCaseStepResult.setWebDriverException(naturalActionException.getErrorStackTraceTruncated());
testCaseStepResult.setErrorCode(snippet.getErrorCode().getErrorCode().intValue());
testCaseStepResult.setMessage(snippet.getErrorMessage());
markTestcaseAborted(testCaseResult, testCaseStepResult, snippet);
testCaseStepResult.getMetadata().setLog(testCaseStepResult.getWebDriverException());
// We are throwing an InvocationTargetException to handle Auto Healing
throw naturalActionException;
} else {
testCaseStepResult.setMessage(snippet.getSuccessMessage());
}
}
Aggregations