【解决】appium测试时,popupwindow元素控件无法定位的问题【Android】

参考:https://testerhome.com/topics/3778

问题:Android,appium测试时,popupwindow控件元素无法定位。

背景:在测试一款Android APP时,在商品详情页,点击加入购物车时,会在商品详情页面弹出popupwindow,其中有选择规格的内容。

用uiautomatorviewer.bat定位不了元素,只能选择popupwindow下面一层的元素。找到Android开发,让加了

View contentView = LayoutInflater.from(mContext).inflate(
                R.layout.pop_window, null);
contentView.setFocusable(true);

上面红色部分,即增加一行设置焦点的代码,重新打包,问题解决。

uiautomatorviewer.bat定位popupwindow中的元素成功。跑了一下appium,也可以成功操作元素了。

原文地址:https://www.cnblogs.com/aikachin/p/7866756.html