Reputation: 59202
I've got the following XPath expression that I call from selenium (technically, from splinter, which is calling selenium):
//label[text()="data"]/following-sibling::div/input|//label[text()="data"]/following-sibling::div/textarea
Is there a way to simplify this expression? The following doesn't work in selenium, although it seems to work in AquaPath:
//label[text()="data"]/following-sibling::div/(input|textarea)
Upvotes: 4
Views: 344
Reputation: 243449
Try:
//label[text()="data"]/following-sibling::div/*[self::input or self::textarea]
Whenever there are many (more than 3 alternatives), an expression like this is considerably shorter:
someExpr/*[contains('|name1|name2|name3|name4|', concat('|',name(), '|'))]
Upvotes: 4