appium-for-mac icon indicating copy to clipboard operation
appium-for-mac copied to clipboard

Bug in findAllUsingBaseUIElement?

Open dougPhilips opened this issue 6 years ago • 2 comments

Context: I am playing around with the examples/other/calculator.py code. It took a bit of tweaking to get working (I cloned this repo 2018-07-09, two days ago as I write this). My "big" changes were to copy utilitiesSaved.py to utilities.py so calculator.py could import it, and then I had to change desiredCapabilities to be: desiredCapabilities = {'platformName': 'Mac', 'deviceName': 'Mac', 'cookies': defaultCookies} And I was off to the races!

I noticed that the Calculator app remembers what windows it had opened (such as the About window and the Paper Tape), so I wanted to get all the top level windows using this XPath: "/AXApplication[@AXTitle='Calculator']/AXWindow[@AXRoleDescription='standard window']"

If I use driver.find_element_by_xpath(...) I find one window, so I thought, why not use driver.find_elements_by_xpath(...) to find all of them, and then I can examine them to see what is what.

Unfortunately, when I do that, instead of getting back a list of elements, I get an exception: selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

I think the bug is here: https://github.com/appium/appium-for-mac/blob/master/AppiumForMac/Server/Controller/AfMElementLocator.m#L196

Notice that line is returning, thinking it found something, but, it is not setting the status to success like it does down on line 215.

Ok, fine, so I just add another slash to the front of my path and convert it to a relative path. Yay, no more exception! But, now my result is not a list, but a dict:

{u'message': u'Success\t The command executed successfully.'}

I would like find_elements_by_xpath to be selenium-friendly and return an empty list successfully when nothing is found, or a list (even of one item) when things are found.

I am running on OSX 10.13.4, python 2.7.15, selenium 3.13.0, Appium 1.6.2, AppiumForMac 1.1.0 (the last two are binary installed, I did not build myself from source)

Thanks!

dougPhilips avatar Jul 12 '18 20:07 dougPhilips

I am seeing issues with driver.findElementsByXpath as well.

andrew041 avatar Jul 13 '18 20:07 andrew041

I am seeing the same thing with latest AppiumForMac V0.4.1. Showing that it detect the element at AXPath, giving code 200 for success, but the array of elmeent is []: [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXApplication[@AXTitle='Word']", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXWindow[@AXTitle='Document1' and @AXIdentifier='_NS:16' and @AXSubrole='AXStandardWindow']", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXSplitGroup[0]", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXSplitGroup[0]", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXSplitGroup[@AXIdentifier='Document Pane']", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXGroup[0]", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXScrollArea[0]", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXLayoutArea[0]", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXGroup[0]", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXGroup[1]", [2020-10-08 01:20:34][Appium4Mac] [STDERR] "AXTextArea[0]" [2020-10-08 01:20:34][Appium4Mac] [STDERR] ) [2020-10-08 01:20:34][Appium4Mac] [STDERR] 2020-10-08 13:20:34.852 AppiumForMac[36542:1474031] [2020-10-08 01:20:34][Appium4Mac] [STDERR] ************* findAllUsingAbsoluteAXPath matchedNodes:( [2020-10-08 01:20:34][Appium4Mac] [STDERR] ) [2020-10-08 01:20:34][Appium4Mac] [STDERR] [2020-10-08 01:20:34][Appium4Mac] [STDERR] [2020-10-08 01:20:34][WD Proxy] Got response with status 200: {"status":0,"sessionId":"Qy54T7IT","value":[]} [2020-10-08 01:20:34][WD Proxy] Replacing sessionId Qy54T7IT with 4f364c7d-1ad8-424d-9e8d-49b5bd49bf15 [2020-10-08 01:20:34][HTTP] <-- POST /wd/hub/session/4f364c7d-1ad8-424d-9e8d-49b5bd49bf15/elements 200

Please let me know how to get this fix?

Also, i found that find_elements instead of find_element seems to be more successful, even though it is return empty array[]. I would like to be able to get to the element of the list and do a send_keys(), but not able to index an empty array. Please help. Been trying to work around this issue for a few weeks now.

jnguyen19 avatar Oct 08 '20 20:10 jnguyen19