1

Not able to click in automation because IU is not properly visible in appium.

Please help me for this issue. Screenshot is given below Appium image attached

Appium version: - 1.15.0 -1.

Java client : - java-client-7.2.0

Desired capability details for appium viewer : -

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

Commands through 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();

Logs for 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

Please help me for this issue.

Tom
  • 2,734
  • 2
  • 22
  • 39
Chetan Ma
  • 11
  • 1
  • 5

2 Answers2

0

Base on your image which you highlight

Try this

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

However, before this statement , you need to do an explicit wait.

Amend :

Are you able to find out in the home tab (which you click) exist the elements that are unique in that page ? Use explicit wait to detect that unique element. If it is present (or visible) , then run your script which you want to click.

Secondly , the view does not seem to be clickable from your image . The clickable property is false.

You will need to find the clickable element . It may be (as your image does not display) in another element at same level that is clickable.

john
  • 413
  • 7
  • 16
  • You have to find out if the page exist first before you run the script. – john Oct 21 '19 at 23:10
  • What is the script to " find out the page exist " – Chetan Ma Oct 22 '19 at 01:53
  • How to check the page exits???..what i feel is the XML wch is getting loading is partial...can u guide us in this..becz the same code is working smoothly in vivo whereas in other mobile like motorola the same script is not working..even we feel that the alignment of the elements after loading is not proper u can refer the image attached above – Chetan Ma Oct 22 '19 at 06:07
  • You can try adding explicit wait till the page load fully as mention in my answer. – john Oct 22 '19 at 06:23
  • As mention, choose an element in the page. Maybe a button or a view. Add explicit wait to it. – john Oct 22 '19 at 06:24
  • I had added explicit wait for all the elements present in that page. But it is not working. – Chetan Ma Oct 22 '19 at 06:34
  • is your explicit wait able to detect any elements (like a button / view in that page) ? – john Oct 22 '19 at 06:48
  • Please refer the below comment ( answer box ). – Chetan Ma Oct 22 '19 at 08:07
0

Please check the logs which we executed just now

there are two buttons one is Illustration button in the home page second is select product in Details section i.e.next page element comes after clicking on illustration button. As u said we have implemented explicit wait in both the buttons before clicking, we did not get any error for illustration as u can check the logs bt the illustration button didnt click and the issue with product selection in the next page is not clicking as well as giving error as no such element even after manually clicking illustration button n navigating to next page.

can u suggest any page loading in appium,this may be because we wrote script to fetch page source before doing operation in the page wherein we found xml is getting loaded partially.

Appium Logs

 [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
Chetan Ma
  • 11
  • 1
  • 5
  • [W3C (b5d9b130)] Calling AppiumDriver.click() with args: ["0b9beaa1-1469-4c07-8c10-cdc2758d555b","b5d9b130-5e84-4675-928f-6ecb5a3f9eef"] I see that the element is click successfully (status 200) – john Oct 22 '19 at 12:48