appium / appium-for-mac

[deprecated] Application for automating a mac app with JSON wire protocol
Apache License 2.0
193 stars 70 forks source link

How to interact with elements without using XPaths? #66

Open tomw93 opened 5 years ago

tomw93 commented 5 years ago

I want to interact with a Mac App without using XPaths and definitely not with Absolute X Paths. This is because any form of XPath is a very flaky way of getting certain elements that are subject to change.

With other automation frameworks on other platforms, getting elements by ID/ Name etc can be used.

How can we find elements in a Mac App by other means? Is there a way to tell AppiumForMac to give me an Id rather than it?

musha34 commented 5 years ago

Yes. You can use ID.

driver.find_elements(by_class, selector)

example

from appium.webdriver.common.mobileby import MobileBy

element = driver.find_elements('id', 'Next')

tomw93 commented 5 years ago

@musha34 that would be ideal if I could use IDs, but how do I know what the IDs are? This is automating a Mac App itself so not mobile.

musha34 commented 5 years ago

then I don't know. I did not do the mac App. I guess you need to find a driver which support element ID.

musha34 commented 5 years ago

@tomw93 You can give this a try https://appiumpro.com/editions/52

tomw93 commented 5 years ago

@musha34 that is the original article I looked at, however it does everything using XPaths - hence my initial question