Reputation:
For example I searching for something in google, than I get search results, and I need to have xpath or any other locator for summarize all links on results page? Any suggestion?
Upvotes: 0
Views: 242
Reputation: 12558
If I were doing this for a google search, first I would get the XPath of a single link. You can do this in Chrome by right clicking a link and selecting Inspect Element
, then right clicking the newly selected element, and then hitting Copy XPath
. Example:
I get //*[@id="rso"]/div[1]/li[1]/div/h3/a
from clicking that. However, this will only select a single element, because of li[1]
and div[1]
, which limit the query. You probably want to change the XPath to //*[@id="rso"]/div/li/div/h3/a
, which selects all 10 search results.
Upvotes: 1