Skip to content
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

python AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector' 해결방법

 

 

 

 

line 26, in <module> play_button = driver.find_element_by_css_selector('button.ytp-large-play-button.ytp-button') AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'

 

라인의 오류해결 방법.

 


이 오류는 driver 객체가 find_element_by_css_selector 메소드를 갖고 있지 않아 발생한 것입니다.

 

이전 코드에서는 webdriver.Chrome() 객체를 생성했지만, 해당 객체에는 find_element_by_css_selector와 같은 WebDriver API가 포함되어 있지 않습니다.

 

해당 메소드를 사용하려면 webdriver.Chrome()으로 생성된 driver 객체의 find_element 메소드를 사용하면 됩니다. 즉, driver.find_element_by_css_selector 대신 driver.find_element(By.CSS_SELECTOR, ...) 형태로 사용해야 합니다.

 

따라서, line 26을 다음과 같이 수정해주시면 됩니다.

 

 
python
from selenium.webdriver.common.by import By
.
.
.
play_button = driver.find_element(By.CSS_SELECTOR, 'button.ytp-large-play-button.ytp-button')
 
로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
2334 컴퓨터잡담 H734GP 공유기 시스템로그 중 >>> Send Offer / Receive Discover / 2023.06.04 51327
2333 파이썬 셀레니움에서의 오류(raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:) 2023.05.10 54599
» 파이썬 python AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector' 해결방법 2023.05.07 47434
2331 컴퓨터잡담 테블릿을 세컨트모니터로??? 2023.04.26 37990
2330 파이썬 DiffusionWrapper has 859.52 M params. 2023.04.21 37308
2329 주식 티피씨글로벌 차트가 너무좋네. 2023.04.16 38415
2328 주식 한창산업 - 아연분말,인산아연,제올라이트,바나듐 생산업체 2023.04.13 38416
2327 주식 최강 한동훈주 2023.04.13 36700
2326 [Docs]스프레드시트 구글 스프레드시트에서 셀값이 특정일에서 현재일과 3일 이내의 범위에 들어오면 이메일을 발송하는 방법 2023.03.26 40416
2325 파이썬 파이썬으로 captCha 분석하여 웹사이트 소스 가져오기 2023.03.25 18961
Board Pagination Prev 1 2 3 4 5 ... 235 Next
/ 235

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소