Appium appium 下的 android.widget.EditText 元素 send_keys 报错

troubl_2014 · 2021年11月22日 · 最后由 troubl_2014 回复于 2021年11月23日 · 2419 次阅读


这个元素是 android.widget.EditText,但是脚本中获取此元素后,send_keys 操作报错 selenium.common.exceptions.InvalidElementStateException: Message: Cannot set the element to '13100000000'. Did you interact with the correct element?,appium inspector 中直接对此元素进行 send_key 也报错,求解

目前解决办法:
定位到此元素,ele.click(), 执行 os.system("adb shell input text 13100000000"),如果有其他好的方案,欢迎留言~

共收到 4 条回复 时间 点赞
troubl_2014 关闭了讨论 11月23日 11:57
troubl_2014 重新开启了讨论 11月23日 11:59

用 xpth 中的父子关系或者兄弟关系定位,或者组合关系定位

你这个页面有很多 android.view.view ,看起来像是个 h5 ,可以看看是不是确实是 h5 ?

如果是,可以切换到 webview 来控制。

陈恒捷 回复

我用 driver.contexts 打印出来是只有 [NATIVE_APP] 的

风飞扬 回复

元素定位应该是没问题的,我用 new UiSelector().text("请输入您的账号") 定位到此元素后,打印元素的 class 属性,text 属性都是可以正常打印出来的,只是执行 send_keys() 操作的时候失败了,我也不是很明白为啥失败

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