본문 바로가기
Python/Selenium

[Selenium] AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'

by pcm9881 2023. 5. 1.

셀레니움 WebDriver에서 find_element_by_css_selector를 제공하지 않습니다.

 

앞으로는 By를 사용해서 쓰셔야합니다.

 

예제

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

driver.find_element(By.CSS_SELECTOR,'#wrap')

By 종류

 CLASS_NAME
 CSS_SELECTOR
 ID
 LINK_TEXT
 NAME
 PARTIAL_LINK_TEXT
 TAG_NAME
 XPATH

 

참조

[Selenium dev webdriver.common.by]: https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.by.html#module-selenium.webdriver.common.by

 

 

728x90

댓글