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());
}
}
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);
}
}
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());
}
}
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);
}
}
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);
}
}
Aggregations