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);
}
}
Aggregations