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.
Below I placed the driver in another location.
After specifying the driver, it still runs successfully.
Like it if you like it ❤!