Selenium install WebDriver latest Chrome driver (with 116/117/118/119)

Time:2024-4-30

catalogs

1、Confirm the browser version

2、Find the corresponding chromedriver version

3. Unzip the chromedriver file and place it in the chrome installation directory.

4. Setting system properties

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)

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)
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.

Selenium install WebDriver latest Chrome driver (with 116/117/118/119)

Just click Stable and select the corresponding driver to download.Selenium install WebDriver latest Chrome driver (with 116/117/118/119)

3. Unzip the chromedriver file and place it in the chrome installation directory.

Selenium install WebDriver latest Chrome driver (with 116/117/118/119)

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.

Selenium install WebDriver latest Chrome driver (with 116/117/118/119)Selenium install WebDriver latest Chrome driver (with 116/117/118/119)Selenium install WebDriver latest Chrome driver (with 116/117/118/119)

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()

Selenium install WebDriver latest Chrome driver (with 116/117/118/119)

  

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()

Recommended Today

vivado Error Summary 1 — WARING:[Labtools 27-3361] the debug hub core was not detected make sure the clock

I can’t open the debug screen of debug after program device, I get the following error: WARING:[Labtools 27-3361] the debug hub core was not detected make sure the clock connected to the debug hub core is a free running clock and is active make sure the BSCAN_SWITCE_USER_MASK device property in vivado hardware manager reflects the […]