Search in sources :

Example 1 with DriverAction

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;
}
Also used : DriverAction(com.testsigma.automator.actions.DriverAction)

Example 2 with DriverAction

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());
    }
}
Also used : ActionResult(com.testsigma.automator.constants.ActionResult) NaturalActionException(com.testsigma.automator.actions.exceptions.NaturalActionException) DriverAction(com.testsigma.automator.actions.DriverAction)

Aggregations

DriverAction (com.testsigma.automator.actions.DriverAction)2 NaturalActionException (com.testsigma.automator.actions.exceptions.NaturalActionException)1 ActionResult (com.testsigma.automator.constants.ActionResult)1