catalogs
2、Find the corresponding chromedriver version
3. Unzip the chromedriver file and place it in the chrome installation directory.
5. Confirm whether chromedriver is installed successfully and how to solve the problem
1、Confirm the browser version
In the address bar of your browser, type chrome://version/, enter and you can see the corresponding version
![Selenium install WebDriver latest Chrome driver (with 116/117/118/119) Selenium install WebDriver latest Chrome driver (with 116/117/118/119)](https://imgs.developpile.com/imgs/2768c1d09995433eadb1d5a6f920a685.png)
2、Find the corresponding chromedriver version
Versions 2.1 114 and earlier can be accessed by clicking on theDownload chromedriverDownload the corresponding file according to the version number (see only major versions)![Selenium install WebDriver latest Chrome driver (with 116/117/118/119) Selenium install WebDriver latest Chrome driver (with 116/117/118/119)](https://imgs.developpile.com/imgs/ac2834af539c44fc8f9a8dcd985838d2.png)
2.2 Version 116 is available by clicking on theDownload chromedriverYou can then download the zip file directly.
2.3 Version 117/118/119 by clicking onGo to Chrome for Testing availability ,
You can see the 117 Stable stable version as well as higher versions of the beta.
Just click Stable and select the corresponding driver to download.![Selenium install WebDriver latest Chrome driver (with 116/117/118/119) Selenium install WebDriver latest Chrome driver (with 116/117/118/119)](https://imgs.developpile.com/imgs/d2bde2ae58064c11827247325cb3cfeb.png)
3. Unzip the chromedriver file and place it in the chrome installation directory.
4. Setting system properties
1. Click My Computer/This Computer>>Right click Properties>>Click Advanced System Settings>>Environmental Variables>>System Variables.
2. Click path in the system variables, click Add, and copy and fill in the installation directory of Chrome, then click OK.
5. Confirm whether chromedriver is installed successfully and how to solve the problem
Execute the following block of code in pycharm and it will be successful if you can open the access browser.
from selenium import webdriver
chromedriver_path = r"C:\Users\AppData\Local\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome(chromedriver_path)
# Login to Baidu
def main():
driver.get("https://baidu.com/")
if __name__ == '__main__':
main()
PS: But if there is a webpage flashback, there are several ways to solve it:
1. Reduce the selenium version to 4.1.1 / 4.5.0.
pip --default-timeout=100 install selenium==4.1.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
2, found that after logging in or flashback, but the version number are corresponding, may be because of the driver’s global variable problem caused by the
2.1 Put driver outside the function, for global won’t flicker
from selenium import webdriver
chromedriver_path = r"C:\Users\AppData\Local\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome(chromedriver_path)
# Login to Baidu
def main():
driver.get("https://baidu.com/")
if __name__ == '__main__':
main()
2.2 Do not set driver as global, put it in function will flashback
from selenium import webdriver
# Login to Baidu
def main():
chromedriver_path =r"C:\Users\AppData\Local\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome(chromedriver_path)
driver.get("https://baidu.com/")
if __name__ == '__main__':
main()
2.3 It is also possible to put the driver inside a function, as long as it is set as a global variable
from selenium import webdriver
# Login to Baidu
def main():
global driver # Set global variables
chromedriver_path =r"C:\Users\AppData\Local\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome(chromedriver_path)
driver.get("https://baidu.com/")
if __name__ == '__main__':
main()