Fetch all nodes (*
), then test the element names for the ones you want using predicates.
//span[text()='{0}']/parent::*/following-sibling::*//*[local-name() = 'textarea' or local-name() = 'input']
If your XPath engine has no support for local-name()
(which seems to be a problem with Selenium, see comments), you will have to repeat the complete statement:
//span[text()='{0}']/parent::*/following-sibling::*//textarea | //span[text()='{0}']/parent::*/following-sibling::*//input
The query you've been trying to use is equivalent to
(//span[text()='{0}']/parent::*/following-sibling::*//textarea) | (//input)
Which also explains the results of switching textarea
and input
.