consider renaming have.js_property to have.property
will this even work for mobile? o_O if .get_property is valid for mobile then we should rename it for sure here...
in the past we named is as have.js_property, because for web it was relevant only because of "javascript context", so we named it with "js_" prefix to emphasize that... But if it has a different from js-based implementation in Appium, and this method is still relevant for mobile context - then we have to rename it from js_property simply to property
So, now the main question is: Is .get_property implemented in Appium, does it differ from .get_attribute in Appium, if yes – how? And how does it differ from raw selenium implementation of get_property/get_attribute
Here's what I've managed to pull from AI-chats. Would be nice to double check the examples in real test runs:
Android Interactions occur through UIAutomator.
-
get_attribute: used to retrieve values of element attributes such as 'content-desc', 'text', 'resource-id', and other properties defined in the Android XML markup.
-
get_property: used to get values that may be accessible through native platform APIs, although its usage is often less common than get_attribute.
Ex:
element = driver.find_element_by_id('com.example:id/myElement')
content_desc = element.get_attribute('content-desc')
print(content_desc)
text_property = element.get_property('text')
print(text_property)
iOS Interactions occur through XCUITest
-
get_attribute: used to get values of element attributes such as 'label', 'value', 'name', and other properties defined in the iOS XML markup.
-
get_property: As with Android, this method is less commonly used but can still be employed to retrieve native properties of elements.
Ex:
element = driver.find_element_by_id('myElement')
label = element.get_attribute('label')
print(label)
value_property = element.get_property('value')
print(value_property)
Difference from 'raw' Selenium Implementation In raw Selenium 'get_attribute' and 'get_property' have distinct roles:
- get_attribute: retrieves the value of an attribute as defined in the HTML markup.
- get_property: retrieves the value of a property of a DOM element, which can be different from the attribute.
Ex:
element = driver.find_element_by_id('myElement')
class_attr = element.get_attribute('class')
print(class_attr)
inner_text = element.get_property('innerText')
print(inner_text)
So: In Appium both 'get_attribute' and 'get_property' interact with native properties of elements rather than through JavaScript. The distinction between them is less pronounced compared to raw Selenium, where 'get_attribute' deals with HTML attributes and 'get_property' deals with DOM properties. In Appium, both methods are used to retrieve information specific to the mobile platform (Android or iOS) but 'get_attribute' is more commonly used.