Issue
With selenium in python, I want to collect data about a user called "GrahamDumpleton" on the website below: https://github.com/GrahamDumpleton/wrapt/graphs/contributors
And this is the block I want to locate with the user name "GrahamDumpleton":
How to locate this block using selenium?
Thank you.
Solution
This can be clearly done with XPath since XPath is the only approach supporting locating elements based on their text content.
So, that user block element can be located with the following XPath:
//li[contains(@class,'contrib-person')][contains(.,'Graham')]
In case you want only the header part of that block this XPath can be used:
//h3[contains(@class,'border-bottom')][contains(.,'Graham')]
So, Selenium code returning those elements can be correspondingly
driver.find_elements(By.XPATH, "//li[contains(@class,'contrib-person')][contains(.,'Graham')]")
And
driver.find_elements(By.XPATH, "//h3[contains(@class,'border-bottom')][contains(.,'Graham')]")
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.