Инспектор Appium не может найти элемент правильно. Таким образом, автоматизация не может выполнять функцию щелчка - PullRequest
0 голосов
/ 21 октября 2019

Невозможно нажать в автоматизации, потому что 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

Пожалуйста, помогите мнепо этому вопросу.

Ответы [ 2 ]

0 голосов
/ 22 октября 2019

Пожалуйста, проверьте журналы, которые мы только что выполнили

есть две кнопки, одна из которых - кнопка «Иллюстрация» на главной странице, вторая - «Выбор продукта» в разделе «Детали». Элемент страницы ienext появляется после нажатия кнопки иллюстрации. Как вы сказали, мы реализовали явное ожидание в обеих кнопках перед нажатием, мы не получили никакой ошибки для иллюстрации, так как вы можете проверить журналы, но кнопка иллюстрации не нажимала, и проблема с выбором продукта на следующей странице также не щелкает. так как выдает ошибку как отсутствие такого элемента даже после того, как вручную нажимаете кнопку иллюстрации 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
0 голосов
/ 22 октября 2019

Основываясь на своем изображении, которое вы выделите

Попробуйте это

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

Однако перед этим утверждением вам нужно сделать явное ожидание.

Исправить:

Можете ли вы найти на главной вкладке (которую вы нажимаете) элементы, которые являются уникальными на этой странице? Используйте явное ожидание, чтобы обнаружить этот уникальный элемент. Если он присутствует (или виден), запустите сценарий, который вы хотите щелкнуть.

Во-вторых, вид, по-видимому, не реагирует на клики на вашем изображении. Кликабельное свойство имеет значение false.

Вам нужно будет найти кликабельный элемент. Это может быть (поскольку ваше изображение не отображается) в другом элементе того же уровня, который можно активировать нажатием.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...