Python DeprecationWarning: executable_path has been deprecated, please pass in a Service object 경고

이유정·2022년 3월 11일
0

Web Automation

목록 보기
2/2
post-thumbnail


Chrome driver를 연결해 코드를 실행하니 해당 경고 메세지가 노출되었다.
정상 실행은 되지만, 붉은 색으로 노출이 되니 거슬려서 해결 방법을 찾아보았다.


기존에는 문제가 없었는데, Selenium4로 업데이트가 되면서 문제가 생긴 모양이다.

driver = webdriver.Chrome('/usr/local/bin/chromedriver')

직접 Chrome Driver 위치로 연결하면 안된다고 한다.
webdriver manager를 설치해 Chrome driver 버전을 맞춰 연결을 하겠다.!



Terminal을 열고

Pip install webdriver-manager

를 입력해 webdriver-manager를 설치한다.

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
driver.get("https://www.naver.com")

기존 코드를 해당 코드로 변경해주면 문제 없이 실행이 가능하다.

Reference

https://www.alpharithms.com/scraping-dynamic-websites-with-webdriver-python-253418/

profile
Software QA Engineer

0개의 댓글