I am trying to click on a button which has the following html structure:
<button class="btn waves-effect waves-light">Login</button>
I would like to click the Login
button, here is my code:
driver = webdriver.Chrome()
driver.get()
driver.find_element("link text", "Login")
the result is:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"link text","selector":"Login"}
can you please help me to figure it out? Many Thanks!
2
Answers
from selenium import webdriver
Initialize the WebDriver
driver = webdriver.Chrome()
Navigate to a URL
driver.get("URL of the web page")
Find the "Login" button by its class name
login_button = driver.find_element_by_class_name("btn")
Click the button
login_button.click()
in selenium4:
not in selenium4:
I hope it can help you!