Search in sources :

Example 91 with AutomatorException

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

the class IosDeviceCommandExecutor method getProcessStreamResponse.

public String getProcessStreamResponse(Process p) throws AutomatorException {
    try {
        String stdOut = IOUtils.toString(p.getInputStream(), StandardCharsets.UTF_8);
        String stdError = IOUtils.toString(p.getErrorStream(), StandardCharsets.UTF_8);
        StringBuilder sb = new StringBuilder();
        sb.append(stdOut);
        sb.append(stdError);
        log.debug("idevice command output - " + sb);
        return sb.toString();
    } catch (Exception e) {
        throw new AutomatorException(e.getMessage());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 92 with AutomatorException

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

the class WebDriverManager method closeAllWindowsExceptMainWindow.

private void closeAllWindowsExceptMainWindow() throws AutomatorException {
    try {
        String mainWindowHandle = getMainWindowHandle();
        if (mainWindowHandle != null) {
            WebDriver sessionDriver = getDriver().getRemoteWebDriver();
            Set<String> sessionHandles = sessionDriver.getWindowHandles();
            log.info("Windows currently open before cleanup : \"" + sessionDriver.getWindowHandles().size() + "\"");
            for (String sessionHandle : sessionHandles) {
                if (!sessionHandle.equals(mainWindowHandle)) {
                    try {
                        sessionDriver.switchTo().window(sessionHandle);
                        sessionDriver.close();
                        log.info("Window with window handle \"" + sessionHandle + "\" is closed");
                    } catch (Exception e) {
                        log.error("Error in closing window with window handle \"" + sessionHandle + "\" , details::" + e.getMessage());
                    }
                }
            }
            log.info("Windows open after cleanup : \"" + sessionDriver.getWindowHandles().size() + "\"");
            // Retaining focus back to the main window
            try {
                sessionDriver.switchTo().window(mainWindowHandle);
                log.info("The focus is changed to the window with window handle \"" + mainWindowHandle + "\"");
            } catch (Exception e) {
                log.error("Error in switching to the window with window handle \"" + mainWindowHandle + "\" , details::" + e.getMessage());
            }
        } else {
            log.error("There is no main window handle associated with the given execution id \"" + getExecutionUuid() + "\"");
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) IOException(java.io.IOException)

Example 93 with AutomatorException

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

the class WaitUntilTextIsAbsentAction method execute.

@Override
public void execute() throws Exception {
    try {
        boolean textNotPresent = getWebDriverWait().until(ExpectedConditions.not(CustomExpectedConditions.textToBePresent(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());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 94 with AutomatorException

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

the class TestPlanRunTask method setupLocalDevice.

protected void setupLocalDevice() throws AutomatorException {
    log.info("Setting up local mobile device");
    try {
        checkDeviceAvailability();
        TestDeviceSettings testDeviceSettings = environment.getEnvSettings();
        setAppiumUrl(testDeviceSettings);
        testDeviceSettings.setDeviceName(mobileDevice.getName());
        testDeviceSettings.setDeviceUniqueId(mobileDevice.getUniqueId());
        if (Platform.Android.equals(getEnvPlatform())) {
            testDeviceSettings.setChromedriverExecutableDir(PathUtil.getInstance().getDriversPath());
        } else if (Platform.iOS.equals(getEnvPlatform())) {
            iosDeviceService.setupWda(mobileDevice);
        }
        environment.setEnvSettings(testDeviceSettings);
        mobileAutomationServerService.installDrivers(this.mobileDevice.getOsName(), this.mobileDevice.getUniqueId());
    } catch (TestsigmaException | DeviceNotConnectedException | MobileLibraryInstallException e) {
        log.error(e.getMessage(), e);
        throw new AutomatorException(e.getMessage(), e);
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) MobileLibraryInstallException(com.testsigma.agent.exception.MobileLibraryInstallException) TestDeviceSettings(com.testsigma.automator.entity.TestDeviceSettings) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) DeviceNotConnectedException(com.testsigma.agent.exception.DeviceNotConnectedException)

Example 95 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException 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

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