我们正在考虑将我们的生产服务器从Ubuntu- desktop 10.04 升级到Ubuntu- server 12.04.
我们在当前的桌面操作系统上运行各种服务,例如Selenium Web Driver.我的问题是Selenium Web Driver可以从基于cli的系统运行吗?
我的直接想法是,它不能,因为它依赖于Firefox,但我希望有人证明我错了!
对于我的研究,我在firefox中做了一些源代码修改并自己构建.为了自动化测试,我选择使用Selenium但不幸的是,我新建的Firefox似乎不支持Selenium.
我做了以下事情:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary("/path/to/firefox/binary")
d = webdriver.Firefox(firefox_binary=binary)
d.get("http://www.google.de")
Run Code Online (Sandbox Code Playgroud)
Firefox确实打开并且响应迅速(我可以在搜索栏中输入一个网站).但过了一会儿,python脚本崩溃并出现以下错误消息:
Traceback (most recent call last):
File "firefox.py", line 7, in <module>
d = webdriver.Firefox(firefox_binary=binary)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
self.binary, timeout),
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 66, in launch_browser
self._wait_until_connectable()
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 109, in _wait_until_connectable
raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a …Run Code Online (Sandbox Code Playgroud) 在我的Linux系统中,我使用Firefox,执行我的程序,我的错误是:
Traceback (most recent call last):
File "shenma_diff_main_v2.py", line 90, in <module>
browser = webdriver.Firefox(profile)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
self.binary, timeout),
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 66, in launch_browser
self._wait_until_connectable()
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 100, 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 constructor, check it for details.
Run Code Online (Sandbox Code Playgroud)
如果我使用root执行我的程序就可以了.