如何使用Android模拟器使用monkeyrunner模拟屏幕旋转?

时间:2015-02-14 15:03:38

标签: android android-emulator rotation genymotion

我使用monkeyrunner脚本在Windows上使用GenyMotion模拟器测试APK。脚本是否可以旋转模拟设备?

2 个答案:

答案 0 :(得分:3)

我不熟悉Monkeyrunner,但如果可以通过Monkeyrunner运行CMD线,您可以运行以下命令:

对于地平线:

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

垂直:

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

答案 1 :(得分:3)

非常感谢Nir H.

我使用以下代码在脚本 - rotate.bat创建了相同的文件夹:

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

并从monkeyrunner中调用它(旋转90度的例子并将其旋转回来):

...

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

...

及其作品! :)