WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Unable to click on element which is visible!

Open akashdiware opened this issue 5 years ago • 23 comments

I am using appium studio to test and verify all the actions on the controls using winappdriver.

Now when i try to click onto an element which is visible it shows following error.

Call to 'tap' failed [element.click()] Error response status: 105 Selenium error: An element command could not be completed because the element is not pointer- or keyboard interactable.

Following is the server log: POST /session/629AEB9F-F93E-46F0-AD48-77BC74E27F35/element/42.7604374.4.-166/click HTTP/1.1 Accept: application/json Connection: keep-alive Content-Length: 2 Content-Type: application/json; charset=UTF-8 Host: 127.0.0.1:4723 User-Agent: admc/wd/1.11.1

{} HTTP/1.1 400 Bad Request Content-Length: 175 Content-Type: application/json

{"status":105,"value":{"error":"element not interactable","message":"An element command could not be completed because the element is not pointer- or keyboard interactable."}}

akashdiware avatar May 28 '20 12:05 akashdiware

1)Did you try this in debug mode by putting break points? Try by adding wait condition before. 2) Identify your element with more than one property. Ex FindelementByName(" " ).findElelementByClassName(" "). I faced an issue where an element is having same identification property at different child level of same control. So adding classname (ex:TextBox) helped to locate it.

VijayHugar avatar May 28 '20 17:05 VijayHugar

Do what @VijayHugar said.

But i'd also like to add. Make sure it's within the same session. I've had some older apps throw alerts that are not part of the session, so I've had to attach to the desktop session not just the app.

fonzi avatar May 29 '20 00:05 fonzi

This is probably because the IsKeyboardFocusable is set to false for that element. Check your spy tool, is this attribute set to False? I have seen times where there was a few options I could use to locate and click the element, make sure there is not a nested element or a better one you should be using. Attempt this first before moving on to second suggestion.

Another workaround is to still locate the element, but instead of using the WinAppDriver .Click() approach, grab the location and use the Actions class to do a generic click given the X & Y coordinates (which can be adjusted if its not clicking the right spot). Something like...

Actions actions = new Actions(session);
WindowsElement element = session.FindElementByName("...");

int offsetX = 10;
int offsetY = 10;

actions.MoveToElement(element, offsetX, offsetY).Click().Perform();

The offsetX & offsetY can be used to adjust the location that is being clicked. This approach will by default click the top left corner of the element which in some cases may not be desirable.

Tree55Topz avatar May 29 '20 12:05 Tree55Topz

The elements are not available for interaction if their .Displayed property is set to false. Is this the only element that's got the properties which meets your search criteria. Maybe there's another hidden element also with which WinAppDriver is trying to interact instead of the one you think it should.

naeemakram avatar May 30 '20 20:05 naeemakram

1)Did you try this in debug mode by putting break points? Try by adding wait condition before. 2) Identify your element with more than one property. Ex FindelementByName(" " ).findElelementByClassName(" "). I faced an issue where an element is having same identification property at different child level of same control. So adding classname (ex:TextBox) helped to locate it.

akashdiware avatar Jun 01 '20 13:06 akashdiware

I have tried all the mentioned suggestion but none is working in my case!

isKeyboardFocusable = True

ifOffscreen = True

Whenever try to print rect coords it is showing nothing just 0,0,0,0

To perform any action we need its coords but its not working as well. I guess winappdriver not updating the source with the current state of an application

akashdiware avatar Jun 01 '20 13:06 akashdiware

This is probably because the IsKeyboardFocusable is set to false for that element. Check your spy tool, is this attribute set to False? I have seen times where there was a few options I could use to locate and click the element, make sure there is not a nested element or a better one you should be using. Attempt this first before moving on to second suggestion.

Another workaround is to still locate the element, but instead of using the WinAppDriver .Click() approach, grab the location and use the Actions class to do a generic click given the X & Y coordinates (which can be adjusted if its not clicking the right spot). Something like...

Actions actions = new Actions(session);
WindowsElement element = session.FindElementByName("...");

int offsetX = 10;
int offsetY = 10;

actions.MoveToElement(element, offsetX, offsetY).Click().Perform();

The offsetX & offsetY can be used to adjust the location that is being clicked. This approach will by default click the top left corner of the element which in some cases may not be desirable. Is keyboardfocusable is showing True but isOffScreen is showing True as well even that element is in View. Its displyed property returning false which is not correct.

How we can click on an element which coordinates are showing 0,0,0,0,0??

akashdiware avatar Jun 01 '20 13:06 akashdiware

@akashdiware are you able to share the code of how you are trying to access that element and a screenshot of what the spy tool shows?

Tree55Topz avatar Jun 01 '20 16:06 Tree55Topz

Hey there any one found any solution for this issue!

akashdiware avatar Jun 03 '20 14:06 akashdiware

@akashdiware are you able to share the code of how you are trying to access that element and a screenshot of what the spy tool shows?

I can not share actual code, but i will explain how i am accessing an element. element = driver.find_element_by_name('name') element.click()

With the above code it is scrolling to the specific element but not performing the click event then it will generate an above mentioned exception!

When an element is get scrolled then again i try to send click event to it but still same exception.

akashdiware avatar Jun 03 '20 14:06 akashdiware

Have you tried any debugging? Possibly throwing that element.click() in a try/catch block and printing out the exception? From this you can also catch the error and try again to determine if its a stability issue with your code.

Tree55Topz avatar Jun 03 '20 21:06 Tree55Topz

Have you tried any debugging? Possibly throwing that element.click() in a try/catch block and printing out the exception? From this you can also catch the error and try again to determine if its a stability issue with your code.

Yes I have tried that to. Wrap that in try catch block but it is not working! Same Exception is there as stated in the first comment of this thread! I have also explored the that other issues with similar problem is still open.

I think Microsoft have stopped working on it.

akashdiware avatar Jun 04 '20 03:06 akashdiware

I dont think the problem is with WinAppDriver, this is a common error can imply the following..

  1. You are not identifying the element in the best way, make sure you are checking that no other elements can be used to identify the same thing. Use the Highlight option on the spy tool
  2. You are not including any sort of stable waits in your code, there are examples of doing this on other posts such as https://github.com/microsoft/WinAppDriver/issues/1151. Key here is to catch errors that would otherwise fail the tests and just wait for the element to be accessible.
  3. The element is not in view and you need to scroll to it. I have implemented ways to do this just sending page.down keys.

This is likely something you will just have to get creative about and implement. Without screenshots of the spy tool or examples of your code, theres not much to go off of

Tree55Topz avatar Jun 05 '20 13:06 Tree55Topz

  1. The identifier which is i am using is very unique to identify it and by going through the page source i can confirm that there is only one element with that identifier.

  2. Even for other elements which are in a clear view throwing the same errors. Although those elements are also unique.

  3. I don't need to add waiting because I am debugging that application with the idle but still it is not working.

  4. And it is strange that even that element is in view but its off screen property is true.

akashdiware avatar Jun 06 '20 18:06 akashdiware

Maybe something is wrong in application's UI. Maybe its some sort of bug,.

naeemakram avatar Jun 07 '20 16:06 naeemakram

Maybe something is wrong in application's UI. Maybe its some sort of bug,.

Yes it might be an issue! But when i use other library like pywinauto to identify same element and perform an event it is working super fine.

akashdiware avatar Jun 07 '20 16:06 akashdiware

What is shown in inspect.exe

anunay1 avatar Sep 09 '20 16:09 anunay1

i am also having the same issue, on the same page i am able to click on few elements without any issue but for some of the elements it says not interactable, though in Inspect.exe it clearly shows keyboardfocusable property True also i can confirm that this is the only unique element so not sure what is wrong

anybody has any luck ? what else i can try, when i find element with assessibilityID i do find element , only thing is i cant perform any action on it

inybks avatar Sep 30 '20 23:09 inybks

i just checked and when i get property and element control through findelementwithassessibilityID , in the properties it shows Displayed False, that could be the reason but on screen it is clearly visible, i will try clicking on the location and will update

inybks avatar Sep 30 '20 23:09 inybks

Any luck or solution here? I am also facing similar issue.

ankursha1 avatar Jan 21 '21 17:01 ankursha1

Let me check and get back to you

On Thu, Jan 21, 2021 at 9:24 AM ankursha1 [email protected] wrote:

Any luck or solution here? I am also facing similar issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1176#issuecomment-764809235, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARGUDZHSJGQTACFJ5FDX4UTS3BPLFANCNFSM4NNBB2EQ .

-- bhupinder...

inybks avatar Jan 21 '21 17:01 inybks

Note: read this only if desktop application is developed using electronjs

Well I have one suggestion if your desktop application is written in JavaScript with electronjs then you can use selenium for it. You can use chrome driver's remote debugging to automate app using selenium.

akashdiware avatar Jan 21 '21 17:01 akashdiware

Let me double check as i think we were able to solve that not clicking problem

On Thu, Jan 21, 2021 at 9:35 AM Akash Diware [email protected] wrote:

Note: only if desktop application is developed using electronjs

Well I have one suggestion if your desktop application is written in JavaScript with electronjs then you can use selenium for it. You can use chrome driver's remote debugging to automate app using selenium.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1176#issuecomment-764816571, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARGUDZEC6CAMZQREZVWAKE3S3BQXJANCNFSM4NNBB2EQ .

-- bhupinder...

inybks avatar Jan 21 '21 18:01 inybks