Format XPath condition for :disabled or :enabled pseudo-classes according to the WHATWG spec. See: https://html.spec.whatwg.org /multipage/semantics-other.html#concept-element-disabled
(self, disabled=True)
| 129 | return xpath |
| 130 | |
| 131 | def _format_disabled_xpath(self, disabled=True): |
| 132 | """Format XPath condition for :disabled or :enabled pseudo-classes |
| 133 | according to the WHATWG spec. See: https://html.spec.whatwg.org |
| 134 | /multipage/semantics-other.html#concept-element-disabled |
| 135 | """ |
| 136 | bool_op = '' if disabled else 'not' |
| 137 | return '''( |
| 138 | ((name(.) = 'button' or name(.) = 'input' or name(.) = 'select' |
| 139 | or name(.) = 'textarea' or name(.) = 'fieldset') |
| 140 | and %s(@disabled or (ancestor::fieldset[@disabled] |
| 141 | and not(ancestor::legend[not(preceding-sibling::legend)]))) |
| 142 | ) |
| 143 | or |
| 144 | ((name(.) = 'option' |
| 145 | and %s(@disabled or ancestor::optgroup[@disabled])) |
| 146 | ) |
| 147 | or |
| 148 | ((name(.) = 'optgroup' and %s(@disabled))) |
| 149 | )''' % (bool_op, bool_op, bool_op) |
| 150 | |
| 151 | def xpath_disabled_pseudo(self, xpath): |
| 152 | """Matches all elements that are disabled:: |
no outgoing calls
no test coverage detected