Search in sources :

Example 1 with ScreenDimensions

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

Aggregations

ScreenDimensions (com.testsigma.agent.dto.ScreenDimensions)1 MobileAutomationServerCommandExecutionException (com.testsigma.agent.exception.MobileAutomationServerCommandExecutionException)1 ActionResult (com.testsigma.automator.constants.ActionResult)1 Dimension (org.openqa.selenium.Dimension)1 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)1