use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class CloseCurrentWindowAction method execute.
@Override
public void execute() throws Exception {
try {
String currWindowHandle = getDriver().getWindowHandle();
getDriver().switchTo().window(currWindowHandle).close();
setSuccessMessage(SUCCESS_MESSAGE);
// Once current window is closed, We cannot perform element/browser actions using driver. So we switch to a window if available.
try {
Set<String> windowHandles = getDriver().getWindowHandles();
if (windowHandles != null) {
for (String window : windowHandles) {
getDriver().switchTo().window(window);
break;
}
}
} catch (Exception e) {
log.error("Current window is closed and no other window/tab is present to switch to. " + "Ignore this exception as natural text action is already done", e);
setSuccessMessage("Current window is closed and no other window/tab is present to switch to.");
return;
}
} catch (NoSuchSessionException e) {
throw new AutomatorException(String.format(FAILURE_MESSAGE));
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class PressKeyAction method execute.
@Override
protected void execute() throws Exception {
try {
Actions actions = new Actions(getDriver());
actions.sendKeys(Keys.valueOf(getTestData().toUpperCase().trim())).build().perform();
setSuccessMessage("Successfully typed given test data.");
} catch (Exception e) {
throw new AutomatorException(String.format(FAILURE_MESSAGE, getTestData()));
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class CurrentWebPageLoadingStatusAction method execute.
@Override
public void execute() throws Exception {
String status = getTestData();
switch(status) {
case ActionConstants.LOADED:
try {
boolean pageLoaded = getWebDriverWait().until(CustomExpectedConditions.waitForPageLoadUsingJS());
Assert.isTrue(pageLoaded, LOADED_FAILURE_MESSAGE);
setSuccessMessage(LOADED_SUCCESS_MESSAGE);
break;
} catch (TimeoutException e) {
throw new AutomatorException(LOADED_FAILURE_MESSAGE, (Exception) e.getCause());
}
case ActionConstants.NOT_LOADED:
try {
boolean pageLoaded = getWebDriverWait().until(CustomExpectedConditions.waitForPageLoadUsingJS());
Assert.isTrue(!pageLoaded, NOT_LOADED_ERROR_MESSAGE);
setSuccessMessage(NOT_LOADED_SUCCESS_MESSAGE);
break;
} catch (TimeoutException e) {
throw new AutomatorException(NOT_LOADED_ERROR_MESSAGE, (Exception) e.getCause());
}
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class DriverSessionsService method driverExecutableExists.
public File driverExecutableExists(String browserNameKey, String browserMajorVersion) throws TestsigmaException {
try {
String driversFolderPath = PathUtil.getInstance().getDriversPath();
String driverPath = AutomatorConfig.getInstance().getAppBridge().getDriverExecutablePath(browserNameKey, browserMajorVersion);
File driverFile = Paths.get(driversFolderPath, driverPath).toFile();
log.info("Checking if driver executable exists at : " + driverFile.getAbsolutePath());
return driverFile.exists() ? driverFile : null;
} catch (AutomatorException e) {
log.error(e.getMessage(), e);
throw new TestsigmaException(e.getMessage(), e);
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class CloudAppBridge method getRunTimeData.
@Override
public String getRunTimeData(String variableName, Long environmentResultId, String sessionId) throws AutomatorException {
try {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
queryParams.add("environmentResultId", environmentResultId.toString());
queryParams.add("sessionId", sessionId);
String url = ServerURLBuilder.runTimeDataURL(variableName, queryParams);
String authHeader = HttpClient.BEARER + " " + agentConfig.getJwtApiKey();
HttpResponse<String> response = webAppHttpClient.get(url, new TypeReference<>() {
}, authHeader);
if (response.getStatusCode() == HttpStatus.NOT_FOUND.value()) {
throw new AutomatorException(AutomatorMessages.getMessage(AutomatorMessages.EXCEPTION_INVALID_TESTDATA, variableName));
}
return response.getResponseEntity();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new AutomatorException(e.getMessage(), e);
}
}
Aggregations