Skip to content
Advertisement

How to click a button on a website by finding its id

When I run the code, the website loads up fine but then it won’t click on the button- an error appears saying the element is not interacterble. What do I need to do to click the button? I am relatively new to this and would be grateful for any help.

I have already tried finding it by id and tag.

page = driver.get("https://kenpreston.co.uk/author/")
element = driver.find_element_by_id('mk-button-31')
element.click()

SOLVED: I used driver.find_element_by_link_text and this worked fine.

Advertisement

Answer

I have checked the website and noticed that mk-button-31 is an id for a div tag and inside it there is an a tag. Try getting the url from the a tag and do another driver.get instead of clicking on it.

Also the whole div tag is not clickable so that is why you are getting this error.

Advertisement