我有一个带有 Selenium 的脚本,它可以在 pc 和服务器上正确运行。几天前它停止了服务器,但我仍然没有弄清楚出了什么问题。我将 Firefox (41.0.2) 和 Selenium (2.53.5) 都设置为与 PC 和本地相似。
通过运行:
from selenium import webdriver
browser = webdriver.Firefox()
使用当前版本,我面临此错误:
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
我应该提到我使用设置 DISPLAY:=1; 运行我的代码。
我决定将 selenium 升级到 3.0.2,但我遇到了:
IOError: [Errno 13] Permission denied: 'geckodriver.log'
根据其他遇到此问题的人的建议,我下载了 geckidriver 并将其放在 /usr/local/bin 中。但是,我仍然无法运行我的代码。奇怪的是代码在电脑上运行没有任何问题!
有什么意见或建议吗?
这是 geckodriver.log 的输出:
(firefox:94561): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
1484733755568 geckodriver INFO Listening on 127.0.0.1:35823
1484733756567 mozprofile::profile INFO Using profile path /tmp/rust_mozprofile.UiIxs53qoUs1
1484733756568 geckodriver::marionette INFO Starting browser /usr/bin/firefox
1484733756573 geckodriver::marionette INFO Connecting to Marionette on localhost:44907
(process:95171): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
Xlib:显示“:1”上缺少扩展“RANDR”。
(firefox:95171): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
(firefox:95171): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
(firefox:95171): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
(firefox:95171): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
谢谢