Appium appium+python:无法对弹窗上的对象进行操作

666 · September 30, 2016 · Last by 666 replied at December 20, 2016 · 1386 hits

如图,测试一微信企业号里的东东,点击下面页面被遮挡之前的按钮后,弹出上面的弹窗。
弹窗上的按钮能定位成功,但是无法响应.click() 操作(clickable 属性为 true),试了下,整个上面弹窗的对象都不能响应.click() 操作,
相反弹窗出现后却可以对下面页面被遮挡的按钮进行 click 操作,请问要怎么才能对上面弹窗上的对象进行操作?
尝试:
print context 后有三个:NATIVE_APP、WEBVIEW_com.tencent.mm:tools 和 WEBVIEW_com.bluestacks.s2p
使用 switch_to.context 转换 context 为 NATIVE_APP 和 WEBVIEW_com.tencent.mm:tools,但都没效果
(环境为:BlueStacks 模拟器 +python2.7+appium 1.4.16)

共收到 8 条回复 时间 点赞

我也有这样的问题,请问楼主解决了嘛

666 #2 · October 03, 2016 Author

#1 楼 @b_88 没解决,已困扰多日了

os.popen("adb shell input tap " + str(dx) + " " + str(dy)) 使用坐标点点击试试

666 #4 · October 09, 2016 Author

#3 楼 @viguss_cn
os.popen("adb shell input tap " + str(676) + " " + str(2218))
坐标设置了,还是点击不了
修改了代码,设置焦点在弹窗上,也不行
奇了怪了
在 UIAutomator 上是能捕获到对象的

先用 cmd 确定 adb shell input tap xxx xxx 命令是否生效
生效的话再写到 py 中 os.system("adb shell input tap xxx xxx") 看是否生效
按坐标来点不应该不生效啊

666 #6 · October 10, 2016 Author

#5 楼 @sailen 已经解决了,开始的时候 UIAutomator 得到的坐标不正确,将弹窗设置焦点后重新得到了新坐标(这个坐标与之前得到的不一样),使用新坐标能点击成功了
os.popen("adb shell input tap " + str(676.0) + " " + str(1783.0))

666 关闭了讨论 10 Oct 16:35

@666
你好:你用的 os.popen("adb shell input tap " + str(676.0) + " " + str(1783.0)) ,其中的 os 是什么东西
如果用 java 如何实现。

666 #9 · December 20, 2016 Author

#8 楼 @lihaiye os 是 python 中执行系统命令 (比如 windows 中的 cmd) 的一个包,使用前要先导入:import os。java 我不怎么熟,你到网上搜搜看 java 中怎么执行 cmd 命令的,比如 adb shell input tap xxx xxx

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up