Search in sources :

Example 11 with ActionResult

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);
    }
}
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 12 with ActionResult

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);
            }
        }
    }
}
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 13 with ActionResult

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

Example 14 with ActionResult

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);
    }
}
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 15 with ActionResult

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

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