Skip to content

Instantly share code, notes, and snippets.

@shs96c
Created October 22, 2014 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shs96c/39cb8dac411be6d7dc46 to your computer and use it in GitHub Desktop.
Save shs96c/39cb8dac411be6d7dc46 to your computer and use it in GitHub Desktop.
diff --git a/10_element_state.html b/10_element_state.html
--- a/10_element_state.html
+++ b/10_element_state.html
@@ -109,77 +109,41 @@
<td></td>
</tr>
</table>
- <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of this, the WebDriver API offers a single command ("getElementAttribute") which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
+ <div class="note">
+ <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of thisend point which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
- <p>The algorithm to implement this MUST be (where <code>name</code> refers to the <code>name</code> parameter of the <code>getElementAttribute</code> command):</p>
+ <p>The end result of this algorithm are values that can be passed to other commands within this specification. Notably, this means that URLs that are returned can be passed to <a href="#widl-WebDriver-get-void-DOMString-url">get</a> and the expected URL will be navigated to.</p>
+ </div>
+
+ <p>The algorithm to implement this MUST give the same output as the following algorithm. Note that <code>name</code> refers to the <code>name</code> parameter of the this command's URL.</p>
<ol>
- <li>If <code>name</code> case insensitively matches "style", the value returned MUST be <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec. Notably, css property names MUST be cased the same as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec.
- <ul>
- <li>It SHOULD be equivalent to obtaining the "cssText" property, with the additional constraint that the same value MUST be returned after a round trip through "executeScript". That is, the following pseudo-code MUST be true (where "driver" is a WebDriver instance, and "element" is a WebElement):
- <pre class="example highlight">
- style = element.get_attribute('style');
- self.driver.execute_script('arguments[0].style = arguments[1]', element, style);
- var recovered = element.get_attribute('style');
- assertEquals(style, recovered);
- </pre>
+ <li>Handle special-cases:
+ <ol>
+ <li>If "<code>name</code>" case insensitively matches "<code>style</code>", then store the value of the "<code>style</code>"" property, <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec as <code>result</code>. Notably, CSS property names must be cased as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec. In addition, color property values must be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
+
+ <li>If "<code>name</code>" case insensitively matches "<code>selected</code>" or "<code>checked</code>", and the element is <a href="#is_selectable">selectable</a>:
+ <ol>
+ <li>If the element supports neither a <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> or <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> check, then store <code>null</code> as <code>result</code>.</li>
+ <li>For an <code>OPTION</code> element, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> as <code>result</code>.</li>
+ <li>In all other cases, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> as <code>result</code>.</li>
+ </ol>
</li>
- <li>Color property values MUST be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
- </ul>
- </li>
- <li>If the result of a Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-hasattribute">hasAttribute(name)</a></code>" (as defined in [[!DOM4]]) returns true:
- <ol>
- <li>Store the result of the Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-getattribute">getAttribute(name)</a></code>" in <code>result</code></li>
- <li>If the attribute <code>name</code> is defined as a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/#boolean-attribute">boolean attribute</a>, the string 'true' MUST be returned if <code>result</code> is true, or null otherwise</li>
- <li>Otherwise, fall through to the <a href="#attribute-final-step">final step</a> in this algorithm.</li>
+ <li>If any of the above steps have been executed, go to the <a href="#attribute-result-coercion">result coercion</a> step of this algorithm.
</ol>
</li>
- <li>If the element is an OPTION element and <code>name</code> case insensitively matches "value":
+
+ <li>Obtain the property indexed by "<code>name</code>" from the element and store this as <code>result</code>. If <code>name</code> case insensitively matches <code>class</code> obtain the <code>className</code> property. Similarly, if <code>name</code> case insensitively matches <code>readonly</code>, obtain the <code>readOnly</code> property.</li>
+
+ <li>If <code>result</code> is <code>null</code> or <code>undefined</code>, or if it is a Ecmascript Object, set the value of <code>result</code> to be the <code>value</code> of the AttributeNode obtained by calling <code>element.getAttributeNode</code> iff that AttributeNode is <code>specified</code>. That is, <code>result<code> is the equivalent of executing the following Ecmascript: <code>var attr = element.getAttribute(name); var result = (attr && attr.specified) ? attr.value : null;</code></li>
+
+ <li name="attribute-result-coercion">Coerce the return value to a DOMString:
<ol>
- <li>If a Javascript call to <code>hasAttribute(name)</code> returns true, then the result of a Javascript call to <code>getAttribute(name)</code> MUST be returned.</li>
- <li>Otherwise, the text content of the OPTION, as returned by a call to <code><a href="#widl-WebElement-getElementText-DOMString">getElementText</a></code>, MUST be returned.</li>
+ <li>If <code>result</code> is a boolean value, use the value <code>"true"</code> if <code>result</code> is true, or <code>null</code> otherwise.</li>
+ <li>if <code>result</code> is <code>null</code> or <code>undefined</code>, use <code>null</code>.</li>
+ <li>In all other cases, ceorce <code>result</code> to a DOMString</code>.</li>
</ol>
- </li>
- <li>If the element is <a href="#is_selectable">selectable</a> and <code>name</code> case insensitively matches "selected", and the element in an INPUT element of type "checkbox" or "radio", the string "true" MUST be returned if the element is <a href="http://www.w3.org/TR/html5/forms.html#concept-fe-checked">checked</a> or null otherwise.</li>
- <li>If the value is expected to be a URL, return the property named <code>name</code>, i.e. a fully resolved URL. A non-normative set of these properties is given below:
- <table class="simple">
- <tr>
- <th>Tag name</th>
- <th>"name" value</th>
- </tr>
- <tr>
- <td>A</td>
- <td>href</td>
- </tr>
- <tr>
- <td>IMG</td>
- <td>src</td>
- </tr>
- </table>
- </li>
- <li>If <code>name</code> is in the table below, and the above stages have not yielded a defined, non-null value, the value of the aliased attribute in the table MUST be used as the argument to a recursive call to <code>getElementAttribute</code> and the result returned. This is to allow for common mis-captitalizations:
- <table class="simple">
- <tr>
- <th>Original property name</th>
- <th>Aliased property name</th>
- </tr>
- <tr>
- <td>class</td>
- <td>className</td>
- </tr>
- <tr>
- <td>readonly</td>
- <td>readOnly</td>
- </tr>
- </table>
- </li>
- <li id="attribute-final-step">Finally, attempt the following steps in order, ceasing when one returns a value:
- <ol>
- <li>Attempt to determine the property of the element with the given <code>name</code>. If this is defined and is not an object, then the named property of the object coerced to a string MUST be returned.</li>
- <li> If a Javascript call to "<code>hasAttribute(name)</code>" returns "true", the result of a Javascript call to "<code>getAttribute(name)</code>" MUST be returned.</li>
- <li>The null value MUST be returned.</li>
- </ol>
- </li>
+ </li>
</ol>
<dl class='parameters'>
<dt>DOMString name</dt>
diff --git a/webdriver-spec.html b/webdriver-spec.html
--- a/webdriver-spec.html
+++ b/webdriver-spec.html
@@ -1242,77 +1242,41 @@
<td></td>
</tr>
</table>
- <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of this, the WebDriver API offers a single command ("getElementAttribute") which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
+ <div class="note">
+ <p>Although the [[!html51]] spec is very clear about the difference between the properties and attributes of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a>, users are frequently confused between the two. Because of thisend point which covers the case of returning either of the value of a <a href='http://w3c.github.io/dom/#element'>Document <code>element</code></a> property or attribute. If a user wishes to refer specifically to an attribute or a property, they should evaluate Javascript in order to be unambiguous.</p>
- <p>The algorithm to implement this MUST be (where <code>name</code> refers to the <code>name</code> parameter of the <code>getElementAttribute</code> command):</p>
+ <p>The end result of this algorithm are values that can be passed to other commands within this specification. Notably, this means that URLs that are returned can be passed to <a href="#widl-WebDriver-get-void-DOMString-url">get</a> and the expected URL will be navigated to.</p>
+ </div>
+
+ <p>The algorithm to implement this MUST give the same output as the following algorithm. Note that <code>name</code> refers to the <code>name</code> parameter of the this command's URL.</p>
<ol>
- <li>If <code>name</code> case insensitively matches "style", the value returned MUST be <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec. Notably, css property names MUST be cased the same as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec.
- <ul>
- <li>It SHOULD be equivalent to obtaining the "cssText" property, with the additional constraint that the same value MUST be returned after a round trip through "executeScript". That is, the following pseudo-code MUST be true (where "driver" is a WebDriver instance, and "element" is a WebElement):
- <pre class="example highlight">
- style = element.get_attribute('style');
- self.driver.execute_script('arguments[0].style = arguments[1]', element, style);
- var recovered = element.get_attribute('style');
- assertEquals(style, recovered);
- </pre>
+ <li>Handle special-cases:
+ <ol>
+ <li>If "<code>name</code>" case insensitively matches "<code>style</code>", then store the value of the "<code>style</code>"" property, <a href="http://dev.w3.org/csswg/cssom/#serialize-a-css-rule">serialized as defined</a> in the [[!CSSOM-VIEW]] spec as <code>result</code>. Notably, CSS property names must be cased as specified in in section 6.5.1 of the [[!CSSOM-VIEW]] spec. In addition, color property values must be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
+
+ <li>If "<code>name</code>" case insensitively matches "<code>selected</code>" or "<code>checked</code>", and the element is <a href="#is_selectable">selectable</a>:
+ <ol>
+ <li>If the element supports neither a <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> or <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> check, then store <code>null</code> as <code>result</code>.</li>
+ <li>For an <code>OPTION</code> element, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-option-selectedness">selectedness</a> as <code>result</code>.</li>
+ <li>In all other cases, store the element's <a href="http://www.w3.org/TR/html51/forms.html#concept-fe-checked">checkedness</a> as <code>result</code>.</li>
+ </ol>
</li>
- <li>Color property values MUST be standardized to <a href='http://www.w3.org/TR/css3-color/#rgba-color'>RGBA color format</a> as described in [[!css3-color]]. If a user agent does not support RGBA then it MUST return a value as 1 for opacity.</li>
- </ul>
- </li>
- <li>If the result of a Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-hasattribute">hasAttribute(name)</a></code>" (as defined in [[!DOM4]]) returns true:
- <ol>
- <li>Store the result of the Javascript call to "<code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#dom-element-getattribute">getAttribute(name)</a></code>" in <code>result</code></li>
- <li>If the attribute <code>name</code> is defined as a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/#boolean-attribute">boolean attribute</a>, the string 'true' MUST be returned if <code>result</code> is true, or null otherwise</li>
- <li>Otherwise, fall through to the <a href="#attribute-final-step">final step</a> in this algorithm.</li>
+ <li>If any of the above steps have been executed, go to the <a href="#attribute-result-coercion">result coercion</a> step of this algorithm.
</ol>
</li>
- <li>If the element is an OPTION element and <code>name</code> case insensitively matches "value":
+
+ <li>Obtain the property indexed by "<code>name</code>" from the element and store this as <code>result</code>. If <code>name</code> case insensitively matches <code>class</code> obtain the <code>className</code> property. Similarly, if <code>name</code> case insensitively matches <code>readonly</code>, obtain the <code>readOnly</code> property.</li>
+
+ <li>If <code>result</code> is <code>null</code> or <code>undefined</code>, or if it is a Ecmascript Object, set the value of <code>result</code> to be the <code>value</code> of the AttributeNode obtained by calling <code>element.getAttributeNode</code> iff that AttributeNode is <code>specified</code>. That is, <code>result<code> is the equivalent of executing the following Ecmascript: <code>var attr = element.getAttribute(name); var result = (attr && attr.specified) ? attr.value : null;</code></li>
+
+ <li name="attribute-result-coercion">Coerce the return value to a DOMString:
<ol>
- <li>If a Javascript call to <code>hasAttribute(name)</code> returns true, then the result of a Javascript call to <code>getAttribute(name)</code> MUST be returned.</li>
- <li>Otherwise, the text content of the OPTION, as returned by a call to <code><a href="#widl-WebElement-getElementText-DOMString">getElementText</a></code>, MUST be returned.</li>
+ <li>If <code>result</code> is a boolean value, use the value <code>"true"</code> if <code>result</code> is true, or <code>null</code> otherwise.</li>
+ <li>if <code>result</code> is <code>null</code> or <code>undefined</code>, use <code>null</code>.</li>
+ <li>In all other cases, ceorce <code>result</code> to a DOMString</code>.</li>
</ol>
- </li>
- <li>If the element is <a href="#is_selectable">selectable</a> and <code>name</code> case insensitively matches "selected", and the element in an INPUT element of type "checkbox" or "radio", the string "true" MUST be returned if the element is <a href="http://www.w3.org/TR/html5/forms.html#concept-fe-checked">checked</a> or null otherwise.</li>
- <li>If the value is expected to be a URL, return the property named <code>name</code>, i.e. a fully resolved URL. A non-normative set of these properties is given below:
- <table class="simple">
- <tr>
- <th>Tag name</th>
- <th>"name" value</th>
- </tr>
- <tr>
- <td>A</td>
- <td>href</td>
- </tr>
- <tr>
- <td>IMG</td>
- <td>src</td>
- </tr>
- </table>
- </li>
- <li>If <code>name</code> is in the table below, and the above stages have not yielded a defined, non-null value, the value of the aliased attribute in the table MUST be used as the argument to a recursive call to <code>getElementAttribute</code> and the result returned. This is to allow for common mis-captitalizations:
- <table class="simple">
- <tr>
- <th>Original property name</th>
- <th>Aliased property name</th>
- </tr>
- <tr>
- <td>class</td>
- <td>className</td>
- </tr>
- <tr>
- <td>readonly</td>
- <td>readOnly</td>
- </tr>
- </table>
- </li>
- <li id="attribute-final-step">Finally, attempt the following steps in order, ceasing when one returns a value:
- <ol>
- <li>Attempt to determine the property of the element with the given <code>name</code>. If this is defined and is not an object, then the named property of the object coerced to a string MUST be returned.</li>
- <li> If a Javascript call to "<code>hasAttribute(name)</code>" returns "true", the result of a Javascript call to "<code>getAttribute(name)</code>" MUST be returned.</li>
- <li>The null value MUST be returned.</li>
- </ol>
- </li>
+ </li>
</ol>
<dl class='parameters'>
<dt>DOMString name</dt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment