Otaku Wiz
Otaku Wiz

Reputation: 203

How do I click on a button that has no ID or HTML using Python Selenium?

I have a script written and have been able to code for buttons that have html but this button that I inspected on this link, doesn't have one.

This is the element for the login button.

<input type="submit" value="login" class="button">

How would I write this line of script to click on this button using selenium & python?

Upvotes: 0

Views: 701

Answers (2)

Senior Pomidor
Senior Pomidor

Reputation: 1925

your element has few attributes, which we can use. Try to find an element which starts with input and has an attribute type='submit'

driver.find_element_by_xpath("//div[@class='content']//input[@type='submit']").click()

Upvotes: 0

undetected Selenium
undetected Selenium

Reputation: 193388

To click on the button with text as Login you can use the following line of code :

browser.find_element_by_xpath("//form[@method='post' and @action='/auth/login/']//input[@class='button' and @value='login']").click()
#or
browser.find_element_by_xpath("//form[@method='post' and @action='/auth/login/']//input[@class='button' and @value='login']").submit()

Upvotes: 1

Related Questions