3131
3232import static io .appium .java_client .MobileCommand .*;
3333
34- public class AppiumDriver extends RemoteWebDriver implements MobileDriver , ContextAware , FindsByIosUIAutomation ,
34+ public class AppiumDriver extends RemoteWebDriver implements MobileDriver , ContextAware , Rotatable , FindsByIosUIAutomation ,
3535 FindsByAndroidUIAutomator , FindsByAccessibilityId {
3636
3737 private final static MobileErrorHandler errorHandler = new MobileErrorHandler ();
@@ -487,6 +487,24 @@ public String getContext() {
487487 return contextName ;
488488 }
489489
490+ @ Override
491+ public void rotate (ScreenOrientation orientation ) {
492+ execute (DriverCommand .SET_SCREEN_ORIENTATION , ImmutableMap .of ("orientation" , orientation .value ().toUpperCase ()));
493+ }
494+
495+ @ Override
496+ public ScreenOrientation getOrientation () {
497+ Response response = execute (DriverCommand .GET_SCREEN_ORIENTATION );
498+ String orientation = response .getValue ().toString ().toLowerCase ();
499+ if (orientation .equals (ScreenOrientation .LANDSCAPE .value ())) {
500+ return ScreenOrientation .LANDSCAPE ;
501+ } else if (orientation .equals (ScreenOrientation .PORTRAIT .value ())) {
502+ return ScreenOrientation .PORTRAIT ;
503+ } else {
504+ throw new WebDriverException ("Unexpected orientation returned: " + orientation );
505+ }
506+ }
507+
490508 @ Override
491509 public WebElement findElementByIosUIAutomation (String using ) {
492510 return findElement ("-ios uiautomation" , using );
@@ -538,4 +556,5 @@ private static CommandInfo postC(String url) {
538556 private static CommandInfo deleteC (String url ) {
539557 return new CommandInfo (url , HttpVerb .DELETE );
540558 }
559+
541560}
0 commit comments