use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class DriverSessionCommand method getUniqueXpath.
public String getUniqueXpath(String sessionId, Platform platform, MobileElement mobileElement) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
GetUniqueXpathAction getUniqueXpathSnippet = new GetUniqueXpathAction();
getUniqueXpathSnippet.setDriver(remoteWebDriver);
getUniqueXpathSnippet.setPlatform(platform);
getUniqueXpathSnippet.setWebElement(mobileElement);
ActionResult result = getUniqueXpathSnippet.run();
if (result.equals(ActionResult.FAILED)) {
log.error(getUniqueXpathSnippet.getErrorMessage());
throw new Exception("Failed to get Unique Xpath" + " : " + getUniqueXpathSnippet.getErrorMessage());
}
return (String) getUniqueXpathSnippet.getActualValue();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);
}
}
use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class DriverSessionCommand method sendKeys.
public void sendKeys(String sessionId, MobileElement mobileElement, String keys) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
if (mobileElement.getWebViewName() != null)
this.switchToContextByName(remoteWebDriver, mobileElement);
SendKeysAction sendKeysAction = new SendKeysAction();
sendKeysAction.setElementPropertiesEntityMap(createElementPropertiesMap(FindByType.XPATH, mobileElement.getXpath()));
sendKeysAction.setTestDataPropertiesEntityMap(createTestDataPropertiesMap(keys));
sendKeysAction.setDriver(remoteWebDriver);
ActionResult result = sendKeysAction.run();
if (ActionResult.FAILED.equals(result)) {
log.error(sendKeysAction.getErrorMessage());
throw new Exception("Failed to send keys to element " + " : " + sendKeysAction.getErrorMessage());
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);
} finally {
if (mobileElement.getWebViewName() != null) {
try {
switchToNativeContext(sessionContainer.getSessionMap().get(sessionId), mobileElement);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);
}
}
}
}
use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class DriverSessionCommand method tap.
public void tap(String sessionId, com.testsigma.agent.request.TapPoint tapPoint) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
TapPointAction tapPointAction = new TapPointAction();
tapPointAction.setTapPoint(new com.testsigma.automator.actions.mobile.TapPoint(tapPoint.getX(), tapPoint.getY()));
tapPointAction.setDriver(remoteWebDriver);
ActionResult result = tapPointAction.run();
if (ActionResult.FAILED.equals(result)) {
log.error(tapPointAction.getErrorMessage());
throw new Exception("Failed to tap at " + tapPoint + " : " + tapPointAction.getErrorMessage());
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);
}
}
use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class DriverSessionCommand method pageScreenshot.
public String pageScreenshot(String sessionId) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
ScreenshotAction screenshotAction = new ScreenshotAction();
screenshotAction.setDriver(remoteWebDriver);
ActionResult result = screenshotAction.run();
if (ActionResult.FAILED.equals(result)) {
log.error(screenshotAction.getErrorMessage());
throw new Exception("Failed to take a screenshot " + " : " + screenshotAction.getErrorMessage());
}
return (String) screenshotAction.getActualValue();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);
}
}
use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class DriverSessionCommand method switchToContextByName.
private void switchToContextByName(RemoteWebDriver remoteWebDriver, MobileElement mobileElement) throws Exception {
SwitchToContextWithNameAction switchToContext = new SwitchToContextWithNameAction();
switchToContext.setTestDataPropertiesEntityMap(createTestDataPropertiesMap(mobileElement.getWebViewName()));
switchToContext.setDriver(remoteWebDriver);
ActionResult result = switchToContext.run();
if (ActionResult.FAILED.equals(result)) {
log.error(switchToContext.getErrorMessage());
throw new Exception("Failed to Switch to context " + " : " + switchToContext.getErrorMessage());
}
}
Aggregations