Reputation: 15
I did a google Search for the word 'Apple' using Selenium.
Using the below xpath i am trying to get hyperlinks only if the search results that has the word 'Cupertino' in it. But it does return nothing!
//a[contains(.,'Apple') and //span/em[contains(.,'Cupertino')]]
Google Search Results Screenshot:
Can someone help me out with correcting the Xpath i used?
Upvotes: 1
Views: 403
Reputation: 52665
Try below XPath
//h3[contains(.,'Apple') and following-sibling::div[contains(.,'Cupertino')]]/a
Upvotes: 1