簡體   English   中英

阿皮 如何在帶有`android:launchMode =“ singleInstance”`標志的活動中查找元素?

[英]Appium. How to findElement on activity that has `android:launchMode=“singleInstance”` flag?

在為本機android應用創建自動化測試時(使用來自webdriver.io + typescript的appium),我遇到了問題。

目前,我正在嘗試通過ID在活動清單中具有android:launchMode="singleInstance"活動上單擊ID。

我遇到一個問題,appium無法在此活動中找到任何元素。 日志看起來像:

[debug] [JSONWP Proxy] Proxying [POST /elements] to [POST http://localhost:8203/wd/hub/session/8938c098-48e6-4e7b-b9fd-4cf69034058c/elements] with body: {"strategy":"id","selector":"callStatus","context":"","multiple":true}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"8938c098-48e6-4e7b-b9fd-4cf69034058c","status":0,"value":[]}
[debug] [MJSONWP] Responding to client with driver.findElements() result: []

順便說一句。 我無法使用UIAutomatorView檢查該活動,看來問題也與此相關。

如果刪除android:launchMode="singleInstance"標志-一切正常。

如何解決這個問題?

如何在具有android:launchMode="singleInstance"標志的活動中查找元素?

如果驅動程序找不到元素,請檢查當前它面對的XML結構: driver.source()

也許它將返回其他活動/片段的XML表示形式。 您還可以仔細檢查當前獲得的上下文數量: driver.contexts();。

如果存在多個NATIVE_APP上下文,則可能需要切換另一個上下文。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM