use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class DriverManager method endSession.
public void endSession() throws AutomatorException {
try {
if (getDriver() != null && (getDriver().getRemoteWebDriver() != null)) {
log.info("Ending session(if exists) with execution UUID - " + executionUuid + " and session ID - " + getSessionId());
RemoteWebDriver driver = getDriver().getRemoteWebDriver();
try {
beforeEndSessionActions();
driver.quit();
} catch (Exception e) {
log.error(e.getMessage(), e);
driver.quit();
}
afterEndSessionActions();
} else {
log.debug("There is no driver session with executionID - " + executionUuid);
}
} catch (Exception e) {
throw new AutomatorException(e.getMessage(), e);
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class TestsigmaDriver method parseCapabilities.
protected Map<String, Object> parseCapabilities(String cap, String capabilityType) throws AutomatorException {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> capabilities;
try {
capabilities = mapper.readValue(cap, Map.class);
} catch (IOException e) {
throw new AutomatorException("Invalid " + capabilityType + " options provided in the desired capabilities configuration.");
}
return capabilities;
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class WaitUntilFileDownloadIsCompleteAction method execute.
@Override
public void execute() throws Exception {
getDriver().navigate().to("chrome://downloads");
try {
String chromeJavaScript = "var tag = document.querySelector('downloads-manager').shadowRoot;" + " var item_tags = tag.querySelectorAll('downloads-item');" + " var item_tags_length = item_tags.length;" + " var progress_lst = [];" + " for(var i=0; i<item_tags_length; i++) {" + " var intag = item_tags[i].shadowRoot;" + " var progress_tag = intag.getElementById('progress');" + " var progress = null;" + " if(progress_tag && progress_tag.value < 100) {" + " progress = progress_tag.value;" + " }" + " if(progress!=null) progress_lst.push(progress);" + " }" + " return progress_lst";
// We create a custom wait with long sleep time. Since we are only allowing max of 120 secs for step level timeout(which
// may not be sufficient for some downloads), we will be giving additional timeout here.
WebDriverWait waiter = new WebDriverWait(getDriver(), 600, 5000);
boolean isDownloadComplted = waiter.until(CustomExpectedConditions.downloadToBeCompletedInChrome(chromeJavaScript));
Assert.isTrue(isDownloadComplted, String.format(FAILURE_MESSAGE, 600));
setSuccessMessage(SUCCESS_MESSAGE);
} catch (TimeoutException e) {
throw new AutomatorException(String.format(FAILURE_MESSAGE, 600), (Exception) e.getCause());
} finally {
getDriver().navigate().back();
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class WaitUntilElementHasValueAction method execute.
@Override
protected void execute() throws Exception {
try {
boolean valueMatching = getWebDriverWait().until(ExpectedConditions.textToBePresentInElementValue(getBy(), getTestData()));
Assert.isTrue(valueMatching, String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout(), getTestData()));
setSuccessMessage(SUCCESS_MESSAGE);
} catch (TimeoutException e) {
throw new AutomatorException(String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout(), getTestData()), (Exception) e.getCause());
}
}
use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.
the class WaitUntilElementIsClickableAction method execute.
@Override
public void execute() throws Exception {
try {
WebElement visibleElement = getWebDriverWait().until(ExpectedConditions.elementToBeClickable(getBy()));
Assert.notNull(visibleElement, String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout()));
setSuccessMessage(SUCCESS_MESSAGE);
} catch (TimeoutException e) {
throw new AutomatorException(String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue(), getTimeout()), (Exception) e.getCause());
}
}
Aggregations