Search in sources :

Example 1 with RunTimeData

use of com.testsigma.sdk.annotation.RunTimeData in project testsigma by testsigmahq.

the class AddonAction method initRunTimeDataVariable.

private void initRunTimeDataVariable() throws AutomatorException {
    try {
        for (Field field : clazz.getDeclaredFields()) {
            RunTimeData runTimeData = field.getAnnotation(RunTimeData.class);
            if (runTimeData != null) {
                log.info("Initializing  Run Time Data for Addon Plugin Action Step - " + runTimeData);
                Object runTimeDataInstance = addonService.getRunTimeDataInstance();
                FieldUtils.writeField(instance, field.getName(), runTimeDataInstance, true);
                log.info("Setting run time data to the main instance - " + field.getName());
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new AutomatorException(e.getMessage(), e);
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Field(java.lang.reflect.Field) RunTimeData(com.testsigma.sdk.annotation.RunTimeData) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) UnreachableBrowserException(org.openqa.selenium.remote.UnreachableBrowserException) UnexpectedTagNameException(org.openqa.selenium.support.ui.UnexpectedTagNameException) MoveTargetOutOfBoundsException(org.openqa.selenium.interactions.MoveTargetOutOfBoundsException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ElementNotDisplayedException(com.testsigma.automator.actions.exceptions.ElementNotDisplayedException)

Example 2 with RunTimeData

use of com.testsigma.sdk.annotation.RunTimeData in project testsigma by testsigmahq.

the class AddonAction method saveRunTimeData.

private void saveRunTimeData() throws AutomatorException {
    log.info("Saving run time data and sending run time data to provider");
    try {
        for (Field field : clazz.getDeclaredFields()) {
            RunTimeData runTimeData = field.getAnnotation(RunTimeData.class);
            if (runTimeData != null) {
                Field runTimeField = getField(instance.getClass(), field.getName());
                runTimeField.setAccessible(true);
                if (runTimeField != null && runTimeField.get(instance) != null) {
                    Field valueField = getField(runTimeField.get(instance).getClass(), "value");
                    valueField.setAccessible(true);
                    String value = (String) valueField.get(runTimeField.get(instance));
                    Field variableNameField = getField(runTimeField.get(instance).getClass(), "key");
                    variableNameField.setAccessible(true);
                    String variableName = (String) variableNameField.get(runTimeField.get(instance));
                    if (variableName != null) {
                        runtimeDataProvider.storeRuntimeVariable(variableName, value);
                        log.info("Setting run time data to RunTimeData Provider - " + field.getName());
                    } else {
                        log.info("Skipping run time data to RunTimeData Provider - as the variable name is empty" + field.getName());
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new AutomatorException(e.getMessage(), e);
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Field(java.lang.reflect.Field) RunTimeData(com.testsigma.sdk.annotation.RunTimeData) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) UnreachableBrowserException(org.openqa.selenium.remote.UnreachableBrowserException) UnexpectedTagNameException(org.openqa.selenium.support.ui.UnexpectedTagNameException) MoveTargetOutOfBoundsException(org.openqa.selenium.interactions.MoveTargetOutOfBoundsException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ElementNotDisplayedException(com.testsigma.automator.actions.exceptions.ElementNotDisplayedException)

Aggregations

ElementNotDisplayedException (com.testsigma.automator.actions.exceptions.ElementNotDisplayedException)2 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)2 RunTimeData (com.testsigma.sdk.annotation.RunTimeData)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MoveTargetOutOfBoundsException (org.openqa.selenium.interactions.MoveTargetOutOfBoundsException)2 UnreachableBrowserException (org.openqa.selenium.remote.UnreachableBrowserException)2 UnexpectedTagNameException (org.openqa.selenium.support.ui.UnexpectedTagNameException)2