Issue
Let's say all Author/username elements in one webpage look like this... How can I get to the href part using python and Selenium? users = browser.find_elements_by_xpath(?)
<span>
Author:
<a href="/account/57608-bob">
bob
</a>
</span>
Thanks.
Solution
Use .//span[contains(text(), "Author")]/a
as xpath expression.
For example:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://jsfiddle.net/9pKMU/show/')
for a in driver.find_elements_by_xpath('.//span[contains(text(), "Author")]/a'):
print(a.get_attribute('href'))
Answered By - falsetru
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.