While using appium how can we change device orientation to landscape mode?

Deadly 提交于 2019-12-07 18:45:35

问题


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.


回答1:


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

  • 'orientation': 'LANDSCAPE'

also with this option it is working :

  • 'deviceorientation': 'LANDSCAPE'



回答2:


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



回答3:


Use this method for landscape mode:

public void rotateDeviceScreenToLandscape() {
        ((Rotatable) driver).rotate(ScreenOrientation.LANDSCAPE);
    }



回答4:


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



来源:https://stackoverflow.com/questions/37167082/while-using-appium-how-can-we-change-device-orientation-to-landscape-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!