I am trying to click on News link on google search page the HTML structure looks like this
I tried following xpaths but none worked
//a/child::span[1][contains(.,'News')]
The following xpath resulted in invalid selector: The result of the xpath expression "//a/child::span/following-sibling::text()[contains(.,'News')]" is: [object Text]. It should be an element.
//a/child::span/following-sibling::text()[contains(.,'News')]
Thanks
You simply need
//a[contains(., "News")]
Note that "News"
is not a part of span
, but a
, so your 1st XPath won't work
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments