코드를 짜는 도중, Webdriver의 경로를 불러올때 계속 해당 에러가 노출되는 것을 확인했다.
DeprecationWarning: executable_path has been deprecated, please pass in a Service object
검색을 통해 확인 시, selenium 버전이 4가 되면서 쓰는 방식이 바뀐 것으로 확인되었다.
1) ChromeDriver
from selenium.webdriver.chrome.service import Service
를 넣어준 뒤, 경로를 재 설정해주면 된다.
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
s = Service('/Users/woonmong/Downloads/chromedriver')
driver = webdriver.Chrome(service=s)
2) 기타 문법들 (ex driver.find_element_by_css_selector...)
아래 코드를 추가하고, find_element 안에 By.~ 로 기재해준다.
from selenium.webdriver.common.by import By
driver.find_element(By.CSS_SELECTOR,'a.top-nav__login-link').click()
3) selenium 버전을 3.X 버전으로 설치하기
아래 명령어를 통해 selenium의 버전을 새로 설치해준다.
(현재 selenium 버전 확인 방법 : selenium.version)
pip install selenium==3.14.0
출처 : https://www.youtube.com/watch?v=VMzmVFA-Gps
출처 : https://stackoverflow.com/questions/61308799/unable-to-locate-elements-in-selenium-python