-
AttributeError: 'str' object has no attribute 'capabilities'트러블 슈팅 2024. 7. 6. 20:21
- AttributeError: 'str' object has no attribute 'capabilities' 오류는 Selenium에서 크롬 웹드라이버를 설정하는 과정에서 발생
- 최신 버전에서는 웹드라이버의 초기화 방법이 변경되었기 때문
- 올바른 초기화 방법은 Service 객체를 사용하는 것
변경 전 코드
from selenium import webdriver driver = webdriver.Chrome('.\chromedriver.exe')
변경 후 코드
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options # Chromedriver 경로 설정 chromedriver_path = '.\chromedriver.exe' # Service 객체 생성 service = Service(chromedriver_path) # Options 객체 생성 options = Options() # WebDriver 객체 생성 driver = webdriver.Chrome(service=service, options=options)
'트러블 슈팅' 카테고리의 다른 글