Home > Blockchain >  Keep getting Unresolved reference 'By' in Selenium
Keep getting Unresolved reference 'By' in Selenium

Time:04-06

im keep getting Unresolved reference 'By'

here is the code:

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.indiegogo.com/explore/home?project_type=campaign&project_timing=all&sort=trending")
driver.implicitly_wait(0.5)
vegetable = driver.find_element(By.CSS_SELECTOR, "tomatoes")

here is an image: enter image description here

CodePudding user response:

add the reference

from selenium.webdriver.common.by import By

CodePudding user response:

first you need to import By
from selenium.webdriver.common.by import By

whole code

from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.indiegogo.com/explore/home?project_type=campaign&project_timing=all&sort=trending")
driver.implicitly_wait(0.5)
vegetable = driver.find_element(By.CSS_SELECTOR, "tomatoes")
  • Related