Selenium Firefox启动,但不打开任何网址

1 投票
3 回答
1827 浏览
提问于 2025-04-18 15:22

我正在使用Python版本的selenium

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys
fp = webdriver.FirefoxProfile("C:\\Users\\%user%\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\fyet0w0h.default")
browser = webdriver.Firefox(firefox_profile=fp)
browser.get("https://helloworld.com/")

火狐浏览器驱动已经打开,但我无法用browser.get("url")加载任何网址。没有使用代理。Python 3.2,火狐31版本

任何帮助都非常感谢。

3 个回答

-1

需要升级selenium。如果你正在使用最新版本的Firefox,应该使用最新版本的selenium。

对于Python,输入这个命令:

pip install -U selenium

对于Java,先删除旧的jar文件,然后从这里下载最新版本 http://www.seleniumhq.org/download/,并把它添加到构建路径中。这样就可以正常使用了。祝你在Firefox上测试愉快!

-1

WebDriver支持以下浏览器和操作系统:

  • 谷歌浏览器(Google Chrome)版本12.0.712.0及以上
  • 互联网浏览器(Internet Explorer)6、7、8、9的32位和64位版本
  • 火狐浏览器(Firefox)版本3.0、3.5、3.6、4.0、5.0、6、7、8、9
  • 歌剧浏览器(Opera)版本11.5及以上
  • HtmlUnit版本2.9
  • 安卓系统(Android)2.3及以上,适用于手机和平板(包括设备和模拟器)
  • 苹果iOS系统(iOS)3及以上,适用于手机(包括设备和模拟器),以及3.2及以上,适用于平板(包括设备和模拟器)

我下载了火狐浏览器9.0.1,结果它可以正常工作。

-1

把Firefox降级到9版并不是个好办法。因为Firefox会自动更新,而且应用程序需要在更新后的版本上进行测试。如果只需要在Firefox 25到27版上测试,那该怎么办呢?我们得先弄清楚为什么网址打不开。首先,试着下载最新的Selenium独立webdriver的jar文件。然后检查一下你的电脑是64位还是32位,根据这个来下载合适的jar文件。

撰写回答