appium / appium-mac2-driver

Next-gen Appium macOS driver, backed by Apple XCTest
Apache License 2.0
116 stars 24 forks source link

Which Appium Mac2Driver locator use in order to find element by @AXIdentifier #150

Closed dizzy-bree closed 1 year ago

dizzy-bree commented 2 years ago

I have a macOS app and writing automation to it. On one of the screens there is a view with 12 randomly generated words. Xpath for each of them would look something like this: "/AXApplication[@AXTitle='Cargo']/AXWindow[@AXTitle='Intro' and @AXSubrole='AXStandardWindow']/AXOpaqueProviderGroup[@AXSubrole='AXOpaqueProviderGrid']/AXStaticText[@AXValue='decide' and @AXIdentifier='NewWildlandWordsView.GeneratedWordWithIndex0']"

Since they are randomly generated, using Xpath is not an option, hence I've asked developers to add IDs. So now, when trying to driver.find_element(By.ID, "NewWildlandWordsView.GeneratedWordWithIndex0") I was hoping to being able to locate those elements, but An element could not be located on the page using the given search parameters. was thrown instead

I'm interested in locating those 12 words.

Also tried self.driver.find_element(By.NAME, "NewWildlandWordsView.GeneratedWordWithIndex0") but with same result.

Would really appreciate any suggestion on which identifier should I use instead or maybe there is something developers can change on application side? Thanks in advance for reply.

mykola-mokhnach commented 1 year ago

You should check the xml page sauce to see which element properties could be used in order to locate it. The list of all supported location strategies is documented at https://github.com/appium/appium-mac2-driver#element-location