@Override public void beforeRotation(WebDriver driver, ScreenOrientation orientation) { messages.add("Externally defined listener: Attempt to change screen orientation. " + "The new screen orientation is " + orientation.toString()); }
@Override public void afterRotation(WebDriver driver, ScreenOrientation orientation) { messages.add("Externally defined listener: The screen orientation has been changed to " + orientation.toString()); }
@Override public void beforeRotation(WebDriver driver, ScreenOrientation orientation) { messages.add("Attempt to change screen orientation. The new screen orientation is " + orientation.toString()); }
@Override public void afterRotation(WebDriver driver, ScreenOrientation orientation) { messages.add("The screen orientation has been changed to " + orientation.toString()); }
protected boolean assertThatRotationListenerWorks(EmptyWebDriver driver, TestListener listener, String prefix) { try { driver.rotate(ScreenOrientation.LANDSCAPE); driver.rotate(ScreenOrientation.PORTRAIT); assertThat(listener.messages, contains(prefix + "Attempt to change screen orientation. The new screen orientation is " + ScreenOrientation.LANDSCAPE.toString(), prefix + "The screen orientation has been changed to " + ScreenOrientation.LANDSCAPE.toString(), prefix + "Attempt to change screen orientation. The new screen orientation is " + ScreenOrientation.PORTRAIT.toString(), prefix + "The screen orientation has been changed to " + ScreenOrientation.PORTRAIT.toString())); return true; } finally { listener.messages.clear(); } }
public static boolean isLandscape(){ log.info(MyLogger.getMethodName()); boolean ret = false; try { log.info("Orientation : " + driver.getOrientation().toString()); ret = driver.getOrientation().toString().contains("landscape"); }catch (Exception e){ e.printStackTrace(); log.error("Error found while getting screen orientation "); if(e.getMessage().contains("right")){ ret = true; } } log.info("isLandscape : " + ret); return ret; }
/** * @see com.github.arachnidium.core.eventlisteners.IContextListener#beforeIsRotated(com.github.arachnidium.core.interfaces.IHasHandle, * org.openqa.selenium.ScreenOrientation) */ @Override @BeforeTarget(targetClass = IContext.class, targetMethod = "rotate") public void beforeIsRotated(@TargetParam IHasHandle handle, @UseParameter(number = 0) ScreenOrientation orientation) { Log.debug("Attempt to rotate screen. Context is " + handle.getHandle() + getActivityDescription(handle) + ", new orientation is " + orientation.toString()); contextListenerProxy.beforeIsRotated(handle, orientation); }
@Override public void whenIsRotated(IHasHandle handle, ScreenOrientation orientation) { Log.debug("Screen was rotated. Context is " + handle.getHandle() + getActivityDescription(handle) + ", new orientation is " + orientation.toString()); contextListenerProxy.whenIsRotated(handle, orientation); }
@Override public void beforeIsRotated(IHasHandle handle, ScreenOrientation orientation) { Log.debug("Attempt to rotate screen. Context is " + handle.getHandle() + getActivityDescription(handle) + ", new orientation is " + orientation.toString()); contextListenerProxy.beforeIsRotated(handle, orientation); }
/** * @see com.github.arachnidium.core.eventlisteners.IContextListener#whenIsRotated(com.github.arachnidium.core.interfaces.IHasHandle, * org.openqa.selenium.ScreenOrientation) */ @Override @AfterTarget(targetClass = IContext.class, targetMethod = "rotate") public void whenIsRotated(@TargetParam IHasHandle handle, @UseParameter(number = 0) ScreenOrientation orientation) { Log.debug("Screen was rotated. Context is " + handle.getHandle() + getActivityDescription(handle) + ", new orientation is " + orientation.toString()); contextListenerProxy.whenIsRotated(handle, orientation); } }