IllegalArgument Exception : Unable to compile

813 Views Asked by At

I am getting IlleagalArgument Exception while retreiving Xpath for a particular node

I need to retrieve the below webpage link which follows the title WebPages ,I tried using the below expression but it is not able compile (Please see the comment section for the html )

page.getNode("//h3[. = 'Webpages:']/following-sibling::/ul[@class='list-entity-locations']/li/a/text()")

This is what I tried but got Exception

java.lang.IllegalArgumentException: Unable to compile

2

There are 2 best solutions below

2
Martin Honnen On BEST ANSWER

The right syntax is following-sibling::ul, not following-sibling::/ul.

0
KunduK On

To looking into html which you have posted there is no : text inside <h3>...</h3> tag. Try the below code.

//h3[. = 'Webpages']/following-sibling::ul[@class='list-entity-locations']/li/a/text()