기타

[크롤링/Chromedrive] AttributeError: 'WebDriver' object has no attribute 'find_element_by_class_name'

데굴데구르르 림 2023. 1. 13. 13:35
728x90

예전에 개발했던 크롤링 프로그램을 다시 테스트해보고 재개발 진행하려고 했는데, 

다음과 같은 오류가 발생했다. 

AttributeError: 'WebDriver' object has no attribute 'find_element_by_class_name'

 

띠용..? 수정한적도없고 분명 잘쓰고 있었는데 …

 

 

알고보니 Selenium 4.3.0부터 find_element_*** 들이 제거 됐다.

참고 : https://github.com/SeleniumHQ/selenium/blob/a4995e2c096239b42c373f26498a6c9bb4f2b3e7/py/CHANGES

 

GitHub - SeleniumHQ/selenium: A browser automation framework and ecosystem.

A browser automation framework and ecosystem. Contribute to SeleniumHQ/selenium development by creating an account on GitHub.

github.com

 

 

앞으로 find_element 또는 find_elements 를 쓰면 될 것 같다.

 

예시)

<div id="id1">hello</div>
<div name="name123">my name is...</name>

수정전 수정후
find_element_by_id('id1') find_element("id", "id1")
find_element_by_name('name123') find_element("name", "name123")
find_element_by_xpath('xpath') find_element("xpath", "xpath")