Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac下开始设置浏览器参数报错 #5

Closed
shelfee opened this issue Sep 21, 2023 · 9 comments
Closed

mac下开始设置浏览器参数报错 #5

shelfee opened this issue Sep 21, 2023 · 9 comments

Comments

@shelfee
Copy link

shelfee commented Sep 21, 2023

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot create default profile directory

@shelfee
Copy link
Author

shelfee commented Sep 21, 2023

/Users/zhangxiaofei.sf/Library/Python/3.8/lib/python/site-packages/urllib3/init.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: urllib3/urllib3#3020
warnings.warn(
2023-09-21 11:38:05.287734 开始解析配置文件
2023-09-21 11:38:05.288128 结束解析配置文件
2023-09-21 11:38:05.300655 开始设置浏览器参数
Traceback (most recent call last):
File "main.py", line 14, in
main()
File "main.py", line 8, in main
huawei = HuaWei("config.ini")
File "/Users/zhangxiaofei.sf/repos/hw_seckill/huawei.py", line 26, in init
self.__browser_setting()
File "/Users/zhangxiaofei.sf/repos/hw_seckill/huawei.py", line 112, in __browser_setting
browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
File "/Users/zhangxiaofei.sf/Library/Python/3.8/lib/python/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in init
super().init(
File "/Users/zhangxiaofei.sf/Library/Python/3.8/lib/python/site-packages/selenium/webdriver/chromium/webdriver.py", line 56, in init
super().init(
File "/Users/zhangxiaofei.sf/Library/Python/3.8/lib/python/site-packages/selenium/webdriver/remote/webdriver.py", line 205, in init
self.start_session(capabilities)
File "/Users/zhangxiaofei.sf/Library/Python/3.8/lib/python/site-packages/selenium/webdriver/remote/webdriver.py", line 289, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
File "/Users/zhangxiaofei.sf/Library/Python/3.8/lib/python/site-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute
self.error_handler.check_response(response)
File "/Users/zhangxiaofei.sf/Library/Python/3.8/lib/python/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot create default profile directory
Stacktrace:
0 chromedriver 0x000000010313ed58 chromedriver + 4336984
1 chromedriver 0x0000000103136dd4 chromedriver + 4304340
2 chromedriver 0x0000000102d63a5c chromedriver + 293468
3 chromedriver 0x0000000102d97fb4 chromedriver + 507828
4 chromedriver 0x0000000102d93668 chromedriver + 489064
5 chromedriver 0x0000000102d91798 chromedriver + 481176
6 chromedriver 0x0000000102dd3e24 chromedriver + 753188
7 chromedriver 0x0000000102d9ca5c chromedriver + 526940
8 chromedriver 0x0000000102d9d908 chromedriver + 530696
9 chromedriver 0x0000000103104da4 chromedriver + 4099492
10 chromedriver 0x0000000103109260 chromedriver + 4117088
11 chromedriver 0x000000010310f4ec chromedriver + 4142316
12 chromedriver 0x0000000103109d60 chromedriver + 4119904
13 chromedriver 0x00000001030e1a34 chromedriver + 3955252
14 chromedriver 0x0000000103126a08 chromedriver + 4237832
15 chromedriver 0x0000000103126b84 chromedriver + 4238212
16 chromedriver 0x0000000103136a4c chromedriver + 4303436
17 libsystem_pthread.dylib 0x00000001a1b0426c _pthread_start + 148
18 libsystem_pthread.dylib 0x00000001a1aff08c thread_start + 8

@muzi-admin
Copy link

关掉Chrome浏览器后,再次启动程序。
猜测应该是有后台打开的Chrome抢占。

@shelfee
Copy link
Author

shelfee commented Sep 21, 2023

我把后台chrome相关所有进程退出后,还是不行,一个错误

@muzi-admin
Copy link

我把后台chrome相关所有进程退出后,还是不行,一个错误

哦,MAC环境我不太了解。猜测可能是Chrome和插件的版本问题。等作者来解答吧。

@ancoka
Copy link
Owner

ancoka commented Sep 21, 2023

看错误是无法创建profile directory,检查下userDataDir配置是否存在引号,存在请把引号去掉尝试一下

@shelfee
Copy link
Author

shelfee commented Sep 21, 2023

不存在引号
image

@ancoka
Copy link
Owner

ancoka commented Sep 21, 2023

我在我mac下未遇到类似的问题,请确认以下内容:

  1. 配置的目录是否存在
  2. Chrome浏览器的版本跟ChromeDriver的版本是否匹配

@shelfee
Copy link
Author

shelfee commented Sep 21, 2023

image
空格我尝试过加转义和不加转义 都不行

@ancoka
Copy link
Owner

ancoka commented Sep 21, 2023

image 空格我尝试过加转义和不加转义 都不行

我测试下来是不需要添加转义符的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants