Pre navigation in selenium webdriver
2 answers
Use the following-sibling axis .
This selects all sibling <div> elements after element1 node:
id('element1')/following-sibling::div This selects the first sibling <div> element after element1 node:
id('element1')/following-sibling::div[1] This selects the first sibling node after element1 node if it is a <div> :
id('element1')/following-sibling::*[1][local-name(.)='div'] All these three examples will be chosen by your element (and perhaps a little more if there are more matches), so choose the one that suits your intentions best.
Note that you can do all this with a simple CSS selector . This is equivalent to the latest XPath. And it will be faster.
#element1 + div +6