Python+Selenium Automation-Specify the chrome driver to run the selenium instance demo, and run the browser driver under the specified location

from selenium import webdriver

options = webdriver.ChromeOptions()
# 指定驱动
driver_path = "D:\pyauto_driver\chromedriver.exe"
driver = webdriver.Chrome(driver_path, options = options)
# 不指定驱动
# driver = webdriver.Chrome(options = options)
print(driver.title)

The normal situation is to place the driver in the root directory, and the name change will not be recognized. If you occasionally change the individual version of the browser, you need to relocate a suitable browser driver to replace the previous one, which is very troublesome.
By specifying the driver, I can put the drivers of many browser versions in the designated location. Later, I can write a method to traverse the drivers. If this driver is not applicable, change to another driver, so that you can frequently change the browser version. Under normal circumstances, our automation is running.

Insert picture description here
Below I placed the driver in another location.

Insert picture description here
After specifying the driver, it still runs successfully.

Insert picture description here
Like it if you like it ❤!

Guess you like

Origin blog.csdn.net/qq_38161040/article/details/108161201