简体   繁体   中英

How I can emulate screen rotation with monkeyrunner with Android emulator?

I use monkeyrunner script for testing APK with GenyMotion emulator at Windows. Is it possible that script rotate emulated device?

I'm not familiar with Monkeyrunner, but if it's possible to run a CMD line via Monkeyrunner you can run the following command:

For horizonatal:

%Your_Genymotion_installation_path%\genyshell -c "rotation setangle 90"

For vertical:

%Your_Genymotion_installation_path%\genyshell -c "rotation setangle 0"

Thanks Nir H.

I have created in the same folder with script - rotate.bat with this code:

"c:\Program Files\Genymobile\Genymotion\genyshell.exe" -c "rotation setangle %1"

and call it from monkeyrunner as (example of rotate 90 degree and rotate it back):

...

print "rotation 90"
res = os.popen('rotate 90').read()
print res

MonkeyRunner.sleep(1)

print "rotation 0"
res = os.popen('rotate 0').read()
print res

...

and its works! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM