1. cmd 창에서
pip install selenium
아래와 같은 설치 error 시
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
requests 2.24.0 requires urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1, but you have urllib3 1.26.15 which is incompatible.
pip uninstall selenium
pip install -U selenium
2. chrome version 확인
제일 우측의 점3 클릭 --> 도움말 --> chrome정보
3. 해당 version에 맞는 chrom webdriver 설치
사이트( http://chromedriver.chromium.org/downloads)에서 위에서 찾은 version에 해당하는 다운로드 찾아서
해당하는 버전확인후(노란색 하이라이트 부분) 클릭하고
노란색부분 클릭
압축을 풀어 python설치폴더로 옮기거나
압축풀때 python설치폴더 지정하여 압축해제
4. 이제 정상적으로 설치됐는지 확인
다음고 같은 코드 python IDLE에서 입력하여 실행하고
>>> import selenium
>>> from selenium import webdriver
>>> from selenium.webdriver.common.keys import Keys
>>> driver = webdriver.Chrome()
여기에서 다음과 같은 에러메세지 나오면
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 111
Current browser version is 81.0.4044.138 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
>>> from selenium.webdriver.chrome.options import Options
>>> options = Options()
>>> options.binary_location = "C:\\Program Files\Google\Chrome\Application\\chrome.exe"
>>> driver = webdriver.Chrome(chrome_options = options)
chrome browser가 뜨는지 확인
다음과 같이 구글 사이트에 접속
>>> driver.get('http://google.com/')
다음과 같이 입력하여 테스트 종료 (위의 크롬 화면 close)
>>> driver.quit()