TA的每日心情 | 无聊 4 天前 |
---|
签到天数: 530 天 连续签到: 2 天 [LV.9]测试副司令
|
1测试积点
问题:
求助:python+selenium 启动 Chrome 时,加载用户配置文件,启动报错
依照网上的设置,代码如下:
- <font face="微软雅黑" size="3">from selenium import webdriver
- options = webdriver.ChromeOptions()
- options.add_argument('--profile-directory=Default')
- options.add_argument('--user-data-dir=C:\Users\admin\AppData\Local\Google\Chrome\User Data\Profile 4')
- browser = webdriver.Chrome(chrome_options=options)
- 报错信息如下:
- Traceback (most recent call last):
- File "C:/Users/admin/PycharmProjects/testdemo/555.py", line 11, in
- browser = webdriver.Chrome(chrome_options=options)
- File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in init
- desired_capabilities=desired_capabilities)
- File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in init
- self.start_session(desired_capabilities, browser_profile)
- File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
- response = self.execute(Command.NEW_SESSION, capabilities)
- File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in execute
- self.error_handler.check_response(response)
- File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
- raise exception_class(message, screen, stacktrace)
- selenium.common.exceptions.WebDriverException: Message: unknown error: cannot create default profile directory
- (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 10.0.14393 x86_64)</font>
复制代码
|
|