Following sibling within an xpath is not working as intended Following sibling within an xpath is not working as intended selenium selenium

Following sibling within an xpath is not working as intended


Since OP was looking for a solution which extracts the text from outside the xpath, the following should do that, albeit in a somewhat awkward manner:

tree.xpath("//*[@class='content']")[0][0].tail

Output:

International

The need for this approach is a result of the way lxml parses the html code:tree.xpath("//*[@class='content']") results in a list of length=1.The first (and only) element in the list - tree.xpath("//*[@class='content']")[0] is a lxml.html.HtmlElement which itself can be treated as a list and also has length=1.

In the tail of the first (and only) element in that lxml.html.HtmlElement hides the desired output...