我一直在编写的脚本运行良好。我刚刚添加了该选项,因此它将使用此代码在 chrome 上打开一个配置文件。
options = webdriver.ChromeOptions
browser = webdriver.Chrome(executable_path=r"C:\Users\princess\AppData\Local\Programs\Python\Python36-32\chromedriver.exe", chrome_options=options)
options.add_argument(r'user-data-dir=C:\Users\princess\AppData\Local\Google\Chrome\User Data')
options.add_argument('--profile-directory=Profile 1')
使用时,我收到此错误代码。
C:\Users\Princess\Desktop>CHBO.py
Traceback (most recent call last):
File "C:\Users\Princess\Desktop\CHBO.py", line 12, in <module>
browser = webdriver.Chrome(executable_path=r"C:\Users\princess\AppData\Local\Programs\Python\Python36-32\chromedriver.exe", chrome_options=options)
File "C:\Users\Princess\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 59, in __init__
desired_capabilities = options.to_capabilities()
TypeError: to_capabilities() missing 1 required positional argument: 'self'
我怎样才能解决这个问题?