Search in sources :

Example 6 with ActionResult

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);
    }
}
Also used : ActionResult(com.testsigma.automator.constants.ActionResult) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) ArrayList(java.util.ArrayList) List(java.util.List) MobileAutomationServerCommandExecutionException(com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException) MobileAutomationServerCommandExecutionException(com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException)

Example 7 with ActionResult

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);
    }
}
Also used : ActionResult(com.testsigma.automator.constants.ActionResult) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) MobileAutomationServerCommandExecutionException(com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException) MobileAutomationServerCommandExecutionException(com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException)

Example 8 with ActionResult

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());
    }
}
Also used : ActionResult(com.testsigma.automator.constants.ActionResult) SwitchToNativeAppContextAction(com.testsigma.automator.actions.mobile.android.switchactions.SwitchToNativeAppContextAction) MobileAutomationServerCommandExecutionException(com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException)

Example 9 with ActionResult

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());
    }
}
Also used : IOSElement(io.appium.java_client.ios.IOSElement) ActionResult(com.testsigma.automator.constants.ActionResult) AndroidElement(io.appium.java_client.android.AndroidElement) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 10 with ActionResult

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;
}
Also used : ActionResult(com.testsigma.automator.constants.ActionResult) SuggestionActionResult(com.testsigma.automator.suggestion.actions.SuggestionActionResult) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Aggregations

ActionResult (com.testsigma.automator.constants.ActionResult)19 MobileAutomationServerCommandExecutionException (com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException)13 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)11 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)3 ArrayList (java.util.ArrayList)3 NaturalActionException (com.testsigma.automator.actions.exceptions.NaturalActionException)2 com.testsigma.automator.actions.mobile (com.testsigma.automator.actions.mobile)2 ScreenDimensions (com.testsigma.agent.dto.ScreenDimensions)1 AddonAction (com.testsigma.automator.actions.AddonAction)1 DriverAction (com.testsigma.automator.actions.DriverAction)1 ElementNotDisplayedException (com.testsigma.automator.actions.exceptions.ElementNotDisplayedException)1 SwitchToContextWithNameAction (com.testsigma.automator.actions.mobile.android.switchactions.SwitchToContextWithNameAction)1 SwitchToNativeAppContextAction (com.testsigma.automator.actions.mobile.android.switchactions.SwitchToNativeAppContextAction)1 SuggestionActionResult (com.testsigma.automator.suggestion.actions.SuggestionActionResult)1 AndroidElement (io.appium.java_client.android.AndroidElement)1 IOSElement (io.appium.java_client.ios.IOSElement)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1