This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Attributes are things returned by getAttribute; returning other things is confusing.
+1 getAttribute should map to the getAttribute function from DOM level 2. A getProperty should be added to access properties. This increases the surface area of the API, but lends itself to more consistent and less surprising behavior.
The conclusion in our last F2F in London was to gather more data points before a decision is made and to write down the algorithm currently used to favour properties instead of arguments first. (Who was assigned to do this? I can't remember.) The arguments in favour of conflation are that users get confused by the difference between attributes and properties, and that the primary userbase for the WebDriver spec are fairly non-technical testers who don't have the willingness to learn that. Arguments against conflation focus on correctness of the API, semantic problems dealing with conflation, and the sheer number of edge cases that lead to a very complex algorithm, which, arguably is even more difficult to explain both to inexperienced and experienced users.
I think that burying our head in the sand about this is going to cause us a lot of problems in the future. In Web Components we don't have reflection[2] between properties and attributes that we normally have in the DOM. Below is an example that has come from a Mozilla implementation bug[1] For the following html <!DOCTYPE html> <custom-checkbox id="check">This is a custom checkbox that has a checked property</custom-checkbox> <script type="text/javascript"> window.GaiaCheckbox = (function(win) { // Extend from the HTMLElement prototype var proto = Object.create(HTMLElement.prototype); /** * Proxy the checked property to the input element. */ Object.defineProperty( proto, 'checked', { get: function() { return this._checked || false; }, set: function(value) { this._checked = value; } }); // Register and return the constructor return document.registerElement('gaia-checkbox', { prototype: proto }); })(window); </script> <gaia-checkbox id="check"></<gaia-checkbox> <script> document.getElementById('check').checked = true; </script> if we do > driver.findElement(By.id('check')).getAttribute('checked'); then we get back false in web components but if we were to make a comparable example with an <input type=checkbox> it would return true because of reflection[2]. I really don't see how we carry on conflating this when there are other web technologies forcing people to learn the difference between attributes and properties. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1113742 [2] https://html.spec.whatwg.org/#reflect
I have split out getElementAttribute and getElementProperty for reasons defined in comment 3. Landed in * https://github.com/w3c/webdriver/commit/3819b63ec5defef42fae013c23e2ed497cca8bfd * https://github.com/w3c/webdriver/commit/5ffeced0e854a848aa516c644248473239058a6e