-1

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

Sayhag
  • 44
  • 4
  • The `class` attribute in the DOM is a space-separated **list** of classes. You need to use only one of those in the `By.class_name` call. – SiKing Jan 27 '23 at 16:09

1 Answers1

1

Try adding this import statement

from selenium.webdriver.common.by import By
Shawn
  • 4,064
  • 2
  • 11
  • 23