Home > Net >  python Selenium find_element
python Selenium find_element

Time:01-28

I had a problem using the Selenium library. I don't know how to use find_element. And I get an error

The button I want to press

my code:

from selenium import webdriver
import time,selenium

driver = webdriver.Chrome(r"./driver/chromedriver")
driver.get("https://cin.guru/g/438694")
driver.maximize_window()
button = driver.find_element(By.class_name,"rounded-md mr-1 text-white font-bold text-base cursor-pointer py-1 px-3 mx-1")
time.sleep(5)
button.click()

but i get this error:

button = driver.find_element(By.class_name,"rounded-md mr-1 text-white font-bold text-base cursor-pointer py-1 px-3 mx-1") NameError: name 'By' is not defined

I would be grateful if someone could help me

CodePudding user response:

Try adding this import statement

from selenium.webdriver.common.by import By
  • Related