While using appium how can we change device orient

2019-05-26 17:46发布

While using appium to test mobile application coded in Angular JS with protractor how can we change simulator orientation to landscape mode? I have added : 'deviceorientation': 'landscape', in config.js file. But it didn't change when i run it.

4条回答
女痞
2楼-- · 2019-05-26 18:02

Use this method for landscape mode:

public void rotateDeviceScreenToLandscape() {
        ((Rotatable) driver).rotate(ScreenOrientation.LANDSCAPE);
    }
查看更多
Viruses.
3楼-- · 2019-05-26 18:14

I solve it with uppercase in capabilities in the config file :

  • 'orientation': 'LANDSCAPE'

also with this option it is working :

  • 'deviceorientation': 'LANDSCAPE'
查看更多
对你真心纯属浪费
4楼-- · 2019-05-26 18:15

Using server capabilities :

orientation - (Sim/Emu-only) start in a certain orientation - LANDSCAPE or PORTRAIT

and also as suggested by @Shekhar Swami using the code you can perform an action like :

(AppiumDriver)driver.rotate(ScreenOrientation.LANDSCAPE);
查看更多
萌系小妹纸
5楼-- · 2019-05-26 18:16

In my case it switches the mode but device remains the same (vertically oriented). To fix that - go to Simulator window - Device - Rotate

查看更多
登录 后发表回答