Reputation: 31
How would you find an element in selenium (with python) of the following html:
<a href="/user/login" onclick="ttweb.UserOperations.Login.OpenLoginPopup({ LoginUrl: '/user/login', RedirectUrl: '/' }); return false;">Login</a>
Upvotes: 0
Views: 11248
Reputation: 193338
As per the HTML you have shared to find the element by href
you can use either of the following:
css_selector
:
driver.find_element_by_css_selector("a[href=/user/login]")
xpath
:
driver.find_element_by_xpath("//a[@href='/user/login']")
xpath
(Multiple Attributes):
driver.find_element_by_xpath("//a[@href='/user/login' and text()='Login']")
Upvotes: 2