Selenium Python WebDriverException(“浏览器似乎已退出”) - 没有特定的错误消息

时间:2016-02-26 11:07:22

标签: python selenium

我尝试使用python在firefox上运行selenium脚本。但我收到一个不明确的错误。我已阅读有关显示的主题,但这不是我的情况。

命令

xvfb-run /usr/bin/python2.7 /var/www/html/selenium-scripts/example.py >> /var/log/selenium 2>&1

脚本

from __future__ import print_function
import logging
import time
import datetime
from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('/usr/local/firefox/firefox')
display = Display(visible=0, size=(1024, 768))

display.start()
print('>> TEST START')
browser = webdriver.Firefox(firefox_binary=binary, timeout=60)
browser.get("http://www.vandeel.com")
print('>> TEST ENDED')

driver.quit()
display.stop()

错误

>> TEST START
Traceback (most recent call last):
  File "/var/www/html/selenium-scripts/example.py", line 16, in <module>
browser = webdriver.Firefox(firefox_binary=binary, timeout=60)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 78, in __init__
self.binary, timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "/usr/local/lib/python2.7/site-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 constructor, check it for details.**

请咨询

0 个答案:

没有答案