Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider renaming have.js_property to have.property #538

Open
yashaka opened this issue May 25, 2024 · 2 comments
Open

consider renaming have.js_property to have.property #538

yashaka opened this issue May 25, 2024 · 2 comments

Comments

@yashaka
Copy link
Owner

yashaka commented May 25, 2024

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

@yashaka
Copy link
Owner Author

yashaka commented Jun 3, 2024

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

Repository owner deleted a comment Jun 3, 2024
@ghost
Copy link

ghost commented Jun 3, 2024

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.

yashaka added a commit that referenced this issue Jun 23, 2024
…perty and have.property_

... and match.native_property

since have.* is more high level than match.* or query.*, I decided to keep have.property_ name more concise and less techy...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant