use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class DriverSessionCommand method findElements.
public List<MobileElement> findElements(String sessionId, Platform platform, ElementSearchCriteria elementSearchCriteria) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
FindElementsAction findElementsAction = new FindElementsAction();
findElementsAction.setDriver(remoteWebDriver);
findElementsAction.setPlatform(platform);
findElementsAction.setElementSearchCriteria(elementSearchCriteria);
ActionResult result = findElementsAction.run();
if (result.equals(ActionResult.FAILED)) {
log.error(findElementsAction.getErrorMessage());
throw new Exception("Failed to fetch searched elements " + " : " + findElementsAction.getErrorMessage());
}
return (List<MobileElement>) findElementsAction.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 back.
public void back(String sessionId) throws MobileAutomationServerCommandExecutionException {
try {
RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
MobileNavigateBackAction mobileNavigateBackAction = new MobileNavigateBackAction();
mobileNavigateBackAction.setDriver(remoteWebDriver);
ActionResult result = mobileNavigateBackAction.run();
if (result.equals(ActionResult.FAILED)) {
log.error(mobileNavigateBackAction.getErrorMessage());
throw new Exception("Failed to navigate back to the previous page " + " : " + mobileNavigateBackAction.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 switchToNativeContext.
private void switchToNativeContext(RemoteWebDriver remoteWebDriver, MobileElement mobileElement) throws Exception {
SwitchToNativeAppContextAction switchToContext = new SwitchToNativeAppContextAction();
switchToContext.setDriver(remoteWebDriver);
ActionResult result = switchToContext.run();
if (ActionResult.FAILED.equals(result)) {
log.error(switchToContext.getErrorMessage());
throw new MobileAutomationServerCommandExecutionException("Failed to Switch to back to native context " + " : " + switchToContext.getErrorMessage());
}
}
use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class MobileElementAction method tapByElementCoOrdinates.
public void tapByElementCoOrdinates(WebElement webElement, AppiumDriver driver) throws Exception {
Point loc = webElement.getLocation();
if (webElement instanceof IOSElement) {
loc = ((IOSElement) webElement).getCenter();
} else if (webElement instanceof AndroidElement) {
loc = ((AndroidElement) webElement).getCenter();
}
int x = loc.getX();
int y = loc.getY();
TapPointAction tapPointAction = new TapPointAction();
tapPointAction.setTapPoint(new com.testsigma.automator.actions.mobile.TapPoint(x, y));
tapPointAction.setDriver(driver);
ActionResult result = tapPointAction.run();
if (ActionResult.FAILED.equals(result)) {
log.error(tapPointAction.getErrorMessage());
throw new Exception("Failed to tap at (" + x + ", " + y + ") : " + tapPointAction.getErrorMessage());
}
}
use of com.testsigma.automator.constants.ActionResult in project testsigma by testsigmahq.
the class SuggestionRunner method tryFix.
protected SuggestionEngineResult tryFix(SuggestionAction snippet, Integer fix) {
SuggestionEngineResult res = new SuggestionEngineResult();
res.setMetaData(new SuggestionEngineResultMetaData());
ActionResult snippetResult = null;
try {
snippetResult = snippet.run();
if (snippetResult == ActionResult.SUCCESS) {
res.setResult(res.getResult() == SuggestionActionResult.Failure ? SuggestionActionResult.Failure : SuggestionActionResult.Success);
res.setSuggestionId(fix);
return res;
} else {
res.setResult(SuggestionActionResult.Failure);
}
} catch (Exception e) {
log.error(e, e);
res.setResult(SuggestionActionResult.Failure);
}
return res;
}
Aggregations