为什么selenium不能在我的mac上正常工作?

2024-06-25 23:30:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我在mac上使用了Python3和selenium 2.53.6,它确实打开了firefox,但没有打开我指定的页面。我试着打开“inventwithpython.com“但是我的程序只会启动firefox并返回这个错误。在

以下是我的代码:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://inventwithpython.com')

我还得到以下错误:

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 108, in _wait_until_connectable % (self.profile.path)) selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /var/folders/4c/gsw7v5b118j406zxj3lxctt40000gn/T/tmpv963_mt0 If you specified a log_file in the FirefoxBinary constructor, check it for details.


Tags: the代码in程序commacdriverselenium
1条回答
网友
1楼 · 发布于 2024-06-25 23:30:12

你能试试这个吗?告诉我发生了什么?在

#!/your/shebang/line/python3

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('/your/path/to/actual/firefox/binary')
driver = webdriver.Firefox(firefox_binary=binary)
driver.get('http://inventwithpython.com')

确保二进制文件的路径是您正常触摸Firefox时启动的实际路径。在

编辑:

哦,在我忘了之前,一定要把这件事做好。只是为了确定。在

^{pr2}$

因为如果我没记错的话,有一个档案的修复程序。所以让我们确定这不是一件事。在

相关问题 更多 >