移动测试基础 Genymotion shell 问题,求更优的解决方法

Joshua Dong · 2014年08月18日 · 最后由 matt gong 回复于 2015年07月13日 · 1559 次阅读

最近在用 Genymotion 做自动化测试。
使用 Genymotion 的部分包括:启动 Genymotion、打开模拟器的 GPS、设置当前的经纬度、关闭模拟器。

启动 Genymotion 的指令比较容易查到(把所有的模拟器存到 device_list 这个列表中,一个一个取出来)

for device in device_list:
    os.popen("player --vm-name '"+ device +"'")

目前比较麻烦的是:打开模拟器的 GPS、设置当前的经纬度
按照网上搜索到各种资料的说明,这里应该使用-c 的参数运行:

os.popen("genyshell -c gps setstatus enabled")
os.popen("genyshell -c gps setlatitude 39.5849")
os.popen("genyshell -c gps setlongitude 116.1824")

但实际运行的时候总是找不到命令而返回参数列表:
所以我现在的做法是使用 Genymotion 提供的另外一种方式,即外部文件存储参数-f:

os.popen("genyshell -f "+ genyshell_path)

这里的 genyshell_path 是存储指令的 genyshell 文件

请问有高手知道为什么-c 的指令在这里不能使用吗?

还有就是我没看到关闭 Genymotion 的命令及方法:
官网提供的只有关闭 genyshell 的方法,而 stackOverFlow 上也是只有人问,没人回答。
求教,有人知道这个关闭模拟器指令吗?

实际中,我使用的方式比较土鳖:
定义获取 pid 的函数

#获取player.exe的pid
def get_player_pid():
    listtask = os.popen("tasklist").read().split('\n')
    for m in listtask:
        if m[:10] == "player.exe" :
            return m[30:35]
            break

再使用命令杀掉这个 pid

#关闭掉当前的genymotion
pid = get_player_pid()
os.popen("taskkill /PID " + str(pid))
print("Close the emulator!")
共收到 1 条回复 时间 点赞

exit or quit
Close Genymotion Shell.

详见:
http://www.cnblogs.com/lashwang/p/3719765.html

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册