This works well for finding button-like HTML elements (specially simplified):
//button[text()='Buy']
| //input[@type='submit' and @value='Buy']
| //a/img[@title='Buy']
Now I need to limit this to context. For example, the Buy button, which appears inside the marked field:
//legend[text()='Flubber']
And this works, (.. leads us to the containing set of fields):
//legend[text()='Flubber']/..//button[text()='Buy']
| //legend[text()='Flubber']/..//input[@type='submit' and @value='Buy']
| //legend[text()='Flubber']/..//a/img[@title='Buy']
But is there a way to simplify this? Unfortunately, these kinds of things do not work:
//legend[text()='Flubber']/..//(
button[text()='Buy']
| input[@type='submit' and @value='Buy']
| a/img[@title='Buy'])
(Note that this is for XPath in the browser, so XSLT solutions will not help.)
source
share