1

无法点击自动化,因为 IU 在 appium 中不正确可见。

请帮我解决这个问题。屏幕截图如下 附上的Appium 图像

Appium 版本:- 1.15.0 -1。

Java客户端:-java-client-7.2.0

appium 查看器所需的功能详细信息:-

{
  "deviceName": "moto",
  "udid": "ZF6222BQKC", 
  "platformVersion": "8.0.0",
  "automationName": "UiAutomator2",
  "autoGrantPermissions": true,
  "appActivity": "com.xyz.eapp.eapp",
  "appPackage": "com.xyz.eapp",
  "platformName": "Android"
}

通过eclipse的命令: -

 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
 capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "8.0.0");
 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "moto");
 capabilities.setCapability(MobileCapabilityType.UDID, "ZF6222BQKC");
 capabilities.setCapability("automationName", "UiAutomator2");
 capabilities.setCapability("appPackage", "com.xyz.eapp");
 capabilities.setCapability("appActivity", "com.xyz.eapp.eapp");
 capabilities.setCapability("autoGrantPermissions",true);
 capabilities.setCapability("unicodeKeyboard", true);
 capabilities.setCapability("resetKeyboard", true);
 capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "3000");
 capabilities.setCapability("noReset", true);
 capabilities.setCapability("fullReset", false);
 //capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
 AndroidDriver<AndroidElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
 driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);

 driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Protection Solution\")").click();

Appium 的日志:-

[info] [35m[HTTP][39m [90m{"using":"-android uiautomator","value":"new UiSelector().text(\"Protection Solution\")"}[39m
[debug] [35m[W3C (fb2a594c)][39m Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().text(\"Protection Solution\")","fb2a594c-c0c7-4f2d-9c52-4661a74fcb1d"]
[debug] [35m[BaseDriver][39m Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [35m[BaseDriver][39m Waiting up to 50000 ms for condition
[debug] [35m[WD Proxy][39m Matched '/element' to command name 'findElement'
[debug] [35m[WD Proxy][39m Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/341338f5-760f-43cd-a763-f5fd07f9633f/element] with body: {"strategy":"-android uiautomator","selector":"new UiSelector().text(\"Protection Solution\")","context":"","multiple":false}
[info] [35m[WD Proxy][39m Got an unexpected response with status 404: {"sessionId":"341338f5-760f-43cd-a763-f5fd07f9633f","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:78)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.chann...
[debug] [35m[W3C][39m Matched W3C error code 'no such element' to NoSuchElementError

请帮我解决这个问题。

4

2 回答 2

0

根据您突出显示的图像

试试这个

driver.findElement (By.xpath(“//android.view.view[@text=‘Protection Solution’]”))

但是,在此语句之前,您需要进行显式等待。

修正 :

您是否能够在主页选项卡(您单击)中找到该页面中唯一的元素?使用显式等待来检测该唯一元素。如果它存在(或可见),则运行您要单击的脚本。

其次,该视图似乎无法从您的图像中单击。clickable 属性为假。

您将需要找到可点击的元素。它可能(因为您的图像未显示)在可点击的同一级别的另一个元素中。

于 2019-10-21T21:27:31.630 回答
0

请检查我们刚才执行的日志

有两个按钮,一个是主页中的插图按钮,第二个是在详细信息部分中选择产品,点击插图按钮后出现下一个页面元素。正如你所说,我们在点击之前在两个按钮中都实现了显式等待,我们没有收到任何插图错误,因为你可以检查日志,因为插图按钮没有点击,下一页中的产品选择问题也没有点击即使在手动单击插图按钮 n 导航到下一页后,也没有这样的元素给出错误。

你能建议在appium中加载任何页面吗,这可能是因为我们在页面中执行操作之前编写了脚本来获取页面源,其中我们发现xml被部分加载。

Appium 日志

 [HTTP] {"using":"xpath","value":"//android.view.View[@text='Illustration']"}
[W3C (b5d9b130)] Calling AppiumDriver.findElement() with args: ["xpath","//android.view.View[@text='Illustration']","b5d9b130-5e84-4675-928f-6ecb5a3f9eef"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 50000 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://localhost:8202/wd/hub/session/74c0477c-ea91-466e-ad4a-20817a11dc2a/element] with body: 

{"strategy":"xpath","selector":"//android.view.View[@text='Illustration']","context":"","multiple":false}
[WD Proxy] Got response with status 200: {"sessionId":"74c0477c-ea91-466e-ad4a-20817a11dc2a","value":{"ELEMENT":"0b9beaa1-1469-4c07-8c10-cdc2758d555b","element-6066-11e4-a52e-4f735466cecf":"0b9beaa1-1469-4c07-8c10-cdc2758d555b"}}
[W3C (b5d9b130)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"0b9beaa1-1469-4c07-8c10-cdc2758d555b","ELEMENT":"0b9beaa1-1469-4c07-8c10-cdc2758d555b"}
[HTTP] <-- POST /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element 200 698 ms - 137
[HTTP] 
[HTTP] --> GET /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/displayed
[HTTP] {}
[W3C (b5d9b130)] Calling AppiumDriver.elementDisplayed() with args: ["0b9beaa1-1469-4c07-8c10-cdc2758d555b","b5d9b130-5e84-4675-928f-6ecb5a3f9eef"]
[WD Proxy] Matched '/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/attribute/displayed' to command name 'getAttribute'
[WD Proxy] Proxying [GET /element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/attribute/displayed] to [GET http://localhost:8202/wd/hub/session/74c0477c-ea91-466e-ad4a-20817a11dc2a/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/attribute/displayed] with body: {}
[WD Proxy] Got response with status 200: {"sessionId":"74c0477c-ea91-466e-ad4a-20817a11dc2a","value":"true"}
[W3C (b5d9b130)] Responding to client with driver.elementDisplayed() result: true
[HTTP] <-- GET /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/displayed 200 26 ms - 14
[HTTP] 
[HTTP] --> GET /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/enabled
[HTTP] {}
[W3C (b5d9b130)] Calling AppiumDriver.elementEnabled() with args: ["0b9beaa1-1469-4c07-8c10-cdc2758d555b","b5d9b130-5e84-4675-928f-6ecb5a3f9eef"]
[WD Proxy] Matched '/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/attribute/enabled' to command name 'getAttribute'
[WD Proxy] Proxying [GET /element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/attribute/enabled] to [GET http://localhost:8202/wd/hub/session/74c0477c-ea91-466e-ad4a-20817a11dc2a/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/attribute/enabled] with body: {}
[WD Proxy] Got response with status 200: {"sessionId":"74c0477c-ea91-466e-ad4a-20817a11dc2a","value":"true"}
[W3C (b5d9b130)] Responding to client with driver.elementEnabled() result: true
[HTTP] <-- GET /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/enabled 200 25 ms - 14
[HTTP] 
[HTTP] --> POST /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/click
[HTTP] {"id":"0b9beaa1-1469-4c07-8c10-cdc2758d555b"}
[W3C (b5d9b130)] Calling AppiumDriver.click() with args: ["0b9beaa1-1469-4c07-8c10-cdc2758d555b","b5d9b130-5e84-4675-928f-6ecb5a3f9eef"]
[WD Proxy] Matched '/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/click' to command name 'click'
[WD Proxy] Proxying [POST /element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/click] to [POST http://localhost:8202/wd/hub/session/74c0477c-ea91-466e-ad4a-20817a11dc2a/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/click] with body: {"element":"0b9beaa1-1469-4c07-8c10-cdc2758d555b"}
[WD Proxy] Got response with status 200: {"sessionId":"74c0477c-ea91-466e-ad4a-20817a11dc2a","value":null}
[W3C (b5d9b130)] Responding to client with driver.click() result: null
[HTTP] <-- POST /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element/0b9beaa1-1469-4c07-8c10-cdc2758d555b/click 200 79 ms - 14
[HTTP] 
[HTTP] --> POST /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element
[HTTP] {"using":"xpath","value":"//android.view.View[@text=\"Protection Solution\"]"}
[W3C (b5d9b130)] Calling AppiumDriver.findElement() with args: ["xpath","//android.view.View[@text=\"Protection Solution\"]","b5d9b130-5e84-4675-928f-6ecb5a3f9eef"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 50000 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://localhost:8202/wd/hub/session/74c0477c-ea91-466e-ad4a-20817a11dc2a/element] with body: {"strategy":"xpath","selector":"//android.view.View[@text=\"Protection Solution\"]","context":"","multiple":false}
[WD Proxy] Got an unexpected response with status 404: {"sessionId":"74c0477c-ea91-466e-ad4a-20817a11dc2a","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:102)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:72)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerCon...
[W3C] Matched W3C error code 'no such element' to NoSuchElementError
[BaseDriver] Waited for 665 ms so far
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://localhost:8202/wd/hub/session/74c0477c-ea91-466e-ad4a-20817a11dc2a/element] with body: {"strategy":"xpath","selector":"//android.view.View[@text=\"Protection Solution\"]","context":"","multiple":false}
[WD Proxy] Got an unexpected response with status 404: {"sessionId":"74c0477c-ea91-466e-ad4a-20817a11dc2a","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:102)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:72)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerCon...
[W3C] Matched W3C error code 'no such element' to NoSuchElementError
[BaseDriver] Waited for 1788 ms so far

[W3C (b5d9b130)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
[W3C (b5d9b130)]     at AndroidUiautomator2Driver.findElOrEls (C:\Users\Admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
[HTTP] <-- POST /wd/hub/session/b5d9b130-5e84-4675-928f-6ecb5a3f9eef/element 404 50639 ms - 446
于 2019-10-22T07:49:22.843 回答