k9b
k9b

Reputation: 1493

Trouble retrieving this element in selenium

<a href="arbitraryURL.com;Token=1" target="_top" h="ID=123,5088.1">Sign in</a>

Hey Guys,

Pretty simple question here but I'm having trouble with it for some odd reason. What is the best way to "grab" this button in selenium (using python but a generalized solution would work as well). Its a button, but its html is not a button which means this has not been working for me.

driver.find_element(By.XPATH, '//button[text()="Sign in"]')

Any help would be great, thanks!

Upvotes: 0

Views: 29

Answers (1)

wpercy
wpercy

Reputation: 10090

You should be able to access it using the a tag instead of button like this

driver.find_element(By.XPATH, "//a[contains(text(), 'Sign in')]")

Selenium docs on locating elements by XPath

and

A good SO answer to help locate an element that contains given text

Upvotes: 1

Related Questions