【发布时间】:2015-11-06 04:46:30
【问题描述】:
这是我正在运行的非常简单的代码:
from selenium import webdriver
driver = webdriver.Firefox()`
这是它在 google 计算实例上导致的错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 77, in __init__
self.binary, timeout),
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 49, in __init__
self.binary.launch_browser(self.profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 98, in _wait_until_connectable
raise WebDriverException("The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary construct
or, check it for details.
在两台机器上我都有
Python 2.7.6Mozilla Firefox 42.0-
locate selenium返回... /usr/local/lib/python2.7/dist-packages/selenium-2.48.0.dist-info/DESCRIPTION.rs ... - 所以,
Selenium 2.48.0 lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty
一台机器在谷歌计算服务器上运行(它出错),一台在 VM VirtualBox 上(它可以工作),但这是我能找到的唯一区别,这并不重要。
还有哪些其他差异可能会在一台机器上导致此错误,而在另一台机器上不会导致此错误?
注意: 我在想也许谷歌计算引擎无法打开浏览器窗口,因为你只能 ssh 进入命令行?那么这个问题就不能解决了吗?
注意: 此代码适用于两台机器:
from selenium import webdriver
driver = webdriver.PhantomJS
但是,我需要使用 Firefox,所以这不是一个解决方案,只是要记住的另一件事。
【问题讨论】:
标签: python firefox ubuntu selenium google-compute-engine