2

我正在尝试在 Python 中运行此代码:

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
profile = webdriver.FirefoxProfile()
browser = webdriver.Firefox(firefox_profile = profile)
# Create a new instance of the Firefox driver
driver = webdriver.Firefox()
# go to the google home page
driver.get("http://www.google.com")

当我运行它时,Firefox 会在一段时间后在空白页面上启动,并保持这种状态。我收到这条消息:

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    browser = webdriver.Firefox(firefox_profile = profile)
  File "/home/fx/EnvDev/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 62, in __init__
    desired_capabilities=capabilities)
  File "/home/fx/EnvDev/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/fx/EnvDev/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 114, in start_session
    'desiredCapabilities': desired_capabilities,
  File "/home/fx/EnvDev/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "/home/fx/EnvDev/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 152, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: ''

我在代理后面的 Ubuntu 12.04 上使用 Firefox 20.0。

4

1 回答 1

0

使用最新版本的 Selenium WebDriver

Python 的 Selenium 更新

  1. 打开 cmd 提示符
  2. 在cmd中找到文件夹C:\Python27\Scripts并输入

pip install -U 硒

在此处输入图像描述

于 2014-02-27T06:56:28.643 回答