1. 程式人生 > 其它 >appium報錯Message: Cannot set the element to ‘XXXX’. Did you interact with the correct element?

appium報錯Message: Cannot set the element to ‘XXXX’. Did you interact with the correct element?

appium+python+android

在定位到模組輸入內容的時候遇到了一個問題

send_keys報錯

appium報錯Message: Cannot set the element to ‘XXXX’. Did you interact with the correct element?

查看了一下資料,說是因為android的模組屬性問題

可輸入的模組屬性為android.widget.EditText

但因為我需要輸入的模組屬性非此屬性所以send_keys失敗

也嘗試了get_value()和其他的輸入方法,均不可行

目前暫未找到方法可以使用send_keys 看其他人說可以通過uiautomator定位(未嘗試,各位可以試試)

目前我遇到的地方為登入,所以使用了driver.press_keycode()方法, 通過unicode鍵盤進行輸入,但是presskeycode要用鍵碼,比較麻煩。

以下是網友給出的uiautomator定位使用方式

driver.find_element_by_android_uiautomator('new UiSelector().text("定位屬性")').send_keys('輸入內容')

  

鍵碼使用方式請參考:https://blog.csdn.net/weixin_40180628/article/details/79169846