use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class DriverSessionCommand method swipe.
public void swipe(String sessionId, List<com.testsigma.agent.request.TapPoint> tapPoints) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
SwipeAction swipeAction = new SwipeAction();
List<com.testsigma.automator.actions.mobile.TapPoint> targetTapPoints = new ArrayList<>();
for (com.testsigma.agent.request.TapPoint tapPoint : tapPoints) {
targetTapPoints.add(new com.testsigma.automator.actions.mobile.TapPoint(tapPoint.getX(), tapPoint.getY()));
}
swipeAction.setTapPoints(targetTapPoints.toArray(new com.testsigma.automator.actions.mobile.TapPoint[2]));
swipeAction.setDriver(remoteWebDriver);
ActionResult result = swipeAction.run();
if (ActionResult.FAILED.equals(result)) {
log.error(swipeAction.getErrorMessage());
throw new Exception("Failed to swipe from " + tapPoints.get(0) + " to " + tapPoints.get(1) + " : " + swipeAction.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 pageSourceElements.
public MobileElement pageSourceElements(String sessionId, Platform platform) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
PageElementsAction pageElementsAction = new PageElementsAction();
pageElementsAction.setDriver(remoteWebDriver);
pageElementsAction.setPlatform(platform);
ActionResult result = pageElementsAction.run();
if (result.equals(ActionResult.FAILED)) {
log.error(pageElementsAction.getErrorMessage());
throw new Exception("Failed to fetch page elements " + " : " + pageElementsAction.getErrorMessage());
}
return (MobileElement) pageElementsAction.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 tapOnElement.
public void tapOnElement(String sessionId, MobileElement mobileElement) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
if (mobileElement.getWebViewName() != null)
this.switchToContextByName(remoteWebDriver, mobileElement);
MobileInspectorTapOnElement mobileInspectorTapOnElement = new MobileInspectorTapOnElement();
mobileInspectorTapOnElement.setElementPropertiesEntityMap(createElementPropertiesMap(FindByType.XPATH, mobileElement.getXpath()));
mobileInspectorTapOnElement.setDriver(remoteWebDriver);
ActionResult result = mobileInspectorTapOnElement.run();
if (ActionResult.FAILED.equals(result)) {
log.error(mobileInspectorTapOnElement.getErrorMessage());
throw new Exception("Failed to tap on element " + " : " + mobileInspectorTapOnElement.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 clearElement.
public void clearElement(String sessionId, MobileElement mobileElement) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
if (mobileElement.getWebViewName() != null)
this.switchToContextByName(remoteWebDriver, mobileElement);
ClearElementAction clearElementAction = new ClearElementAction();
clearElementAction.setElementPropertiesEntityMap(createElementPropertiesMap(FindByType.XPATH, mobileElement.getXpath()));
clearElementAction.setDriver(remoteWebDriver);
ActionResult result = clearElementAction.run();
if (ActionResult.FAILED.equals(result)) {
log.error(clearElementAction.getErrorMessage());
throw new Exception("Failed to clear element " + " : " + clearElementAction.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 getScreenDimensions.
public ScreenDimensions getScreenDimensions(String sessionId) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
ScreenDimensionsAction screenDimensionsAction = new ScreenDimensionsAction();
screenDimensionsAction.setDriver(remoteWebDriver);
ActionResult result = screenDimensionsAction.run();
if (result.equals(ActionResult.FAILED)) {
log.error(screenDimensionsAction.getErrorMessage());
throw new Exception("Failed to get device screen dimensions " + " : " + screenDimensionsAction.getErrorMessage());
}
ScreenDimensions screenDimensions = new ScreenDimensions();
Dimension dimension = (Dimension) screenDimensionsAction.getActualValue();
screenDimensions.setScreenHeight(dimension.getHeight());
screenDimensions.setScreenWidth(dimension.getWidth());
return screenDimensions;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);
}
}
Aggregations