Search in sources :

Example 11 with MobileAutomationServerCommandExecutionException

use of com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException 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 MobileAutomationServerCommandExecutionException

use of com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException 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 MobileAutomationServerCommandExecutionException

use of com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException 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 MobileAutomationServerCommandExecutionException

use of com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException 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 MobileAutomationServerCommandExecutionException

use of com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException in project testsigma by testsigmahq.

the class DeviceCommand method back.

public void back(String uniqueId) throws MobileAutomationServerCommandExecutionException {
    try {
        MobileDevice mobileDevice = deviceContainer.getDevice(uniqueId);
        commandExecutor.executeCommand(mobileDevice.iDevice, "input keyevent KEYCODE_BACK");
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new MobileAutomationServerCommandExecutionException(e.getMessage(), e);
    }
}
Also used : MobileAutomationServerCommandExecutionException(com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException) MobileAutomationServerCommandExecutionException(com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException)

Aggregations

MobileAutomationServerCommandExecutionException (com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException)15 ActionResult (com.testsigma.automator.constants.ActionResult)12 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)11 com.testsigma.automator.actions.mobile (com.testsigma.automator.actions.mobile)2 ArrayList (java.util.ArrayList)2 ScreenDimensions (com.testsigma.agent.dto.ScreenDimensions)1 SwitchToNativeAppContextAction (com.testsigma.automator.actions.mobile.android.switchactions.SwitchToNativeAppContextAction)1 List (java.util.List)1 Dimension (org.openqa.selenium.Dimension)1