自首次报道以来已经过去了 6 年:https ://github.com/SeleniumHQ/selenium/issues/854
从这里https://chromedriver.chromium.org/getting-started我尝试这个代码:
import time
from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(60) # Let the user actually see something!
driver.quit()
Run Code Online (Sandbox Code Playgroud)
当它启动时,转到 chrome://version/ 并查看:
配置文件路径 C:\Users\USERCU~1\AppData\Local\Temp\scoped_dir13280_930640861\Default
为了设置某些配置文件,我尝试了这里的代码How to load default profile in Chrome using Python Selenium Webdriver?
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\user123\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 16") #Path to your chrome profile
w = webdriver.Chrome(executable_path="C:\\Users\\chromedriver.exe", …Run Code Online (Sandbox Code Playgroud) python selenium google-chrome selenium-chromedriver selenium-webdriver