I am unable to find the id to this button so it makes it unclickable to me how do I press it?

Viewed 40

I dont know how to click a button in selenium without the id can anyone help me? I have already tried the class but it wont work.

enter image description here

2 Answers

There is no id. You need to use other locator. For example css selector.

driver.find_element_by_css_selector(
            ".btn.btn-secondary.btn-lg.btn-block") 

Also, wait for this element to be clickable before clicking it. Check my other answers

you can use any attribute , as there is an data attribute use that :

Xpath:

//button[@data-track="Sign In"]

CSS:

button[data-track="Sign In"]

You can also use :

//button[contains(text(),"Sign In")]

sytax for xpath or css is :

xpath:

//tagname[@attribute="value"]

css:

tagname[attribute="value"]

so you can check for any attribute and its value. not only id

Related