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

Add keywords to fetch differentiated element Attribute or Property #1822

Closed
emanlove opened this issue May 17, 2023 · 3 comments
Closed

Add keywords to fetch differentiated element Attribute or Property #1822

emanlove opened this issue May 17, 2023 · 3 comments
Labels
acknowledge To be acknowledged in release notes enhancement priority: high rc 1
Milestone

Comments

@emanlove
Copy link
Member

Selenium 4 add the capabilities to get the element's actual property or attribute based upon the value found within the DOM. These differ from the previous implementation which could get either based upon the context.

References:

get_dom_attribute method
get_property method
Selenium 4 - Element Attribute and Property Methods

@emanlove emanlove added this to the V6.2.0 milestone May 17, 2023
@emanlove
Copy link
Member Author

Some of my initial notes on Element Attributes and Properties

  • add Get DOM Attribute, Get Properties as keywords

Questions either worth asking or expected from end users

  • What is the difference between an attribute and a property?
  • What's the difference between this get dom attribute versus get attribute?
  • Should I convert all of my get attributes over to get dom attribute?
  • Will these ever be merged together?
  • Should Get DOM Attribute or Get Attribute on error reference the other under certain conditions?

@emanlove
Copy link
Member Author

emanlove commented Jun 1, 2023

I ask over on the Selenium Slack channel about the difference between an attribute and a property, asking

... is there a good definition of what is/should be an attribute versus a property? For attribute my initial assumption would be it is the Element Content Attribute (as defined in the w3c html spec). Properties seem to be .. well, not sure how to say it .. a browser specific value??

Jim Evans, a Selenium core developer, responded with

Generally speaking, in the W3C world, attributes are actual attributes in the HTML markup, and properties are properties that are part of the EcmaScript Interface Description Language (IDL) of the object. The properties are just as standardized as the attributes (see MDN for proof). Often, properties and attributes overlap, but sometimes they don't. Most people don't understand the difference between attributes and properties, and never need to care, so Selenium (possibly confusingly) uses the generic term "attribute" to refer to "some characteristic of an element that might be represented by a JavaScript property, but also might be an attribute set in the HTML markup." The W3C working group, wanting to be more precise, created two different end points for the different specific meanings.

This reinforces my idea that one can get a list of DOM attributes from the HTML spec; in particular Section 4 Sematics which covers all the elements. These are attributes one sees when looking at the DOM. It should be noted that not all attribute are visible but still have a "value".

The properties of an element are also documented. For example an HTML Element will have these properties. Properties can be seen by through Chrome's DevTools. Or they can be inquire through the Console tab within Chrome using dir method. For example, under the Checkboxes page of The-Internet we could query the properties (and methods) of the input checkbox element using console.dir($('#checkboxes input')[0]).

emanlove added a commit to emanlove/robotframework-seleniumlibrary that referenced this issue Aug 9, 2023
@emanlove emanlove modified the milestones: v6.2.0, v6.3.0 Nov 19, 2023
@emanlove
Copy link
Member Author

Fixed in #1850

@emanlove emanlove added enhancement priority: high acknowledge To be acknowledged in release notes and removed in progress labels Dec 19, 2023
@emanlove emanlove added the rc 1 label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledge To be acknowledged in release notes enhancement priority: high rc 1
Projects
None yet
Development

No branches or pull requests

1 participant