gpt4 book ai didi

python - 无法使用 Selenium Webdriver 运行 Firefox

转载 作者:行者123 更新时间:2023-12-04 18:34:44 24 4
gpt4 key购买 nike

我正在尝试在 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。

最佳答案

使用最新版本的 Selenium WebDriver

Python 的 Selenium 更新

  • 打开cmd提示
  • 找到文件夹 C:\Python27\Scripts在 cmd
    并输入

  • pip install -U selenium



    enter image description here

    关于python - 无法使用 Selenium Webdriver 运行 Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16608342/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com