赞
踩
运行客户端:Pycharm
运行程序如下:
- from selenium import webdriver
- from selenium.webdriver.chrome.options import Options
-
-
- options = Options()
- wd = webdriver.Chrome(chrome_options=options, executable_path=r'c:\chromedriver\chromedriver.exe')
Run之后出现的错误如下。
TypeError: WebDriver.__init__() got an unexpected keyword argument 'chrome_options'/'executable_path'
而此时在Pycharm中,selenium的版本是 4.15.2的新版本,包括urllib3的版本。
参阅:Selenium |AttributeError: 'WebDriver' object has no attribute 'find_element_by_class_name' - 老表爱技术https://www.cnblogs.com/rychh/p/17146472.html
- import time,os,re
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.chrome.options import Options
- from selenium.webdriver.chrome.service import Service
-
- service = Service(executable_path=r'c:\chromedriver\chromedriver.exe)
- options = webdriver.ChromeOptions()
- driver = webdriver.Chrome(service=service, options=options)
- #......
- driver.quit()
- 可参阅:
- https://stackoverflow.com/questions/76550506/typeerror-webdriver-init-got-an-unexpected-keyword-argument-executable-p
萌新公众号 欢迎关注。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。