作者yuuyoru (朝久)
看板Python
標題[問題] python + Appium問題
時間Tue Oct 29 13:47:22 2019
https://imgur.com/a/cELeNf3
想要點擊APP工具列的按鈕
但是按鈕元素不是沒有ID,就是ID重複 (ClassName也重覆)
Name在新版APPIUM已無法使用 (雖然很多也沒text)
目前嘗試了三個寫法,但是都沒法定位到元素
想請教各位大大,是哪裡有問題
----------------------------------------------
1.Xpath 方式
driver.find_element_by_xpath('//android.widget.LinearLayout/android.support.v7.app.ActionBar.Tab[1]/android.widget.LinearLayout/android.widget.ImageView').click()
按照層級去寫入元素,但是運行超過十分鐘還定位不到元素,後來APPIUM server就斷線
了
urllib3.exceptions.ProtocolError: ('Connection aborted.',
RemoteDisconnected('Remote end closed connection without response'))
2.text轉成 Xpath 方式
driver.find_element_by_xpath("//*[@text='订单']").click()
想定位按鈕下方的文字,但是跟上面一樣,運行很久後就斷線
3.uiautomator 方式
driver.find_element_by_android_uiautomator('new
UiSelector().className("\android.support.v7.app.ActionBar.Tab\").clickable(true)').click()
運行後出現錯誤訊息,An element could not be located on the page using the
given search parameters
看起來是在介面中找不到指定的元素
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.125.4.230 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1572328047.A.4F9.html
推 s860134: 根據我的經驗 android 定位多數情形不會超過 3 秒 10/31 20:16
→ s860134: 你可能先釐清一下 是 find element 卡了還是 click 卡了 10/31 20:17
→ s860134: 另外最好可以附上 appium 的log 會更好診斷 10/31 20:18