java - 在 Appium - Eclipse 中找不到主要活动(具有第 3 方工具抽屉菜单)元素
问题描述
Eclipse 查找元素的代码:
`
System.out.println("Context"+driver.getContext() + "Activity: " +
driver.currentActivity());
//Finding element action_search
try{
driver.findElement(By.id("com.shopioca.shop:id/action_search")).click();}catch(Exception e){}
try{
driver.findElement("android.widget.TextView", "com.shopioca.shop:id/action_search").click();}catch(Exception e1){}
try{
driver.findElementByAccessibilityId("Find Order").click();}catch(Exception e1){}
try{
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.shopioca.shop:id/action_search\")").click();}catch(Exception e1){}
try{
driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().resourceId(\"com.shopioca.shop:id/action_search\")")).click();}catch(Exception e1){}
try{
driver.findElementByClassName("android.widget.TextView").click();}catch(Exception e1){}
try{
driver.findElementByXPath("//android.widget.TextView[contains(@resource-id,'com.shopioca.shop:id/action_search')]").click();}catch(Exception e1){}
try{
driver.findElementByXPath("//android.widget.TextView[contains(@condent-desc,'Find Order')]").click();}catch(Exception e1){}
try{
driver.findElementByXPath("//android.support.v7.widget.LinearLayoutCompat[@index='3']/android.widget.TextView[@index='0']").click();}catch(Exception e1){}
`
Appium 服务器 - 错误:
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[contains(@resource-id,'com.shopioca.shop:id/action_search')]","context":"","multiple":false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.TextView[contains(@resource-id,'com.shopioca.shop:id/action_search')]' using 'XPATH' with the contextId: '' multiple: false
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.TextView[contains(@resource-id,'com.shopioca.shop:id/action_search')]' using 'XPATH' with the contextId: '' multiple: false
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[debug] [BaseDriver] Waited for 21331 ms so far
在此页面中找不到任何元素。在主活动页面中找到并成功登陆的登录活动元素。但我在此页面中找不到任何元素。请指教,先谢谢了。
解决方案
安装 Appium-UiAutomator2-driver 解决了查找抽屉菜单元素的问题。
推荐阅读
- c# - 如何在 Azure 中列出经典虚拟机
- sql - TOAD ORA-01821: 日期格式无法识别
- android - 安卓工作室 | NEGOTIATE 身份验证错误:提供的名称无效(机制级别:KrbException:找不到默认领域)
- python-3.x - 未找到 PYD 文件
- python - 如何在不重命名图像的情况下解决此问题。ValueError: int() 以 10 为底的无效文字:'1 (1)'
- html - 仅带空格的输入字段不允许以角度保存?
- r - R从分组数据框到桑基图
- javascript - 将 django 变量传递给 javascript
- nsmutablearray - 为什么我会在 NSMutableArray 中得到“预期的 lambda 表达式主体”?
- node.js - "insufficient authentication scopes" from Google API when calling from K8S cluster