python - 页面未在 Windows 上使用 Python 加载到 Selenium WebDriver 中

标签 python selenium firefox webdriver

我在 Windows 计算机上使用 Python 3.5。当我在 Mac 上运行这段代码时,它运行得很好,没有任何问题。但是当我将代码带到我的 Windows 计算机上时,它不起作用。

基本上显示的是空白页面而不是主页。我没有收到任何错误消息。

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://www.google.com')
cookies = driver.get_cookies()

print(cookies)

关闭网络浏览器后,我会在 shell 中收到以下消息:

“浏览器似乎已退出” selenium.common.exceptions.WebDriverException:消息:浏览器似乎在我们连接之前已退出。如果您在 FirefoxBinary 构造函数中指定了 log_file,请检查它的详细信息。

根据我在网上找到的信息(大多数是针对 Java 的),看来我可能需要设置一个配置文件?这是正确的吗?有人可以帮忙吗?

最佳答案

您的客户端似乎没有修复启动 gecko 驱动程序的新开关:

https://github.com/SeleniumHQ/selenium/commit/c76917839c868603c9ab494d8aa0e9d600515371

如果您要使用 geckodriver v0.10.0 及更高版本,请确保您安装了最新的测试版 (selenium-3.0.0b2):

pip install -U selenium --pre

请注意,您需要 --pre 标志来安装测试版本。

关于python - 页面未在 Windows 上使用 Python 加载到 Selenium WebDriver 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39300553/

相关文章:

python - 输出上传文件中表中存储的文件名?

python对象,垃圾收集

testing - 如何仅在 Selenium 的特定 div 中单击按钮?

java - 获取网页中最后加载的元素

Maven在运行testng测试用例时抛出错误

html - 我怎样才能开始使用 css3

javascript - document.onkeydown 在 Firefox 中不起作用

javascript - Firefox 无重启插件 : What information are available to the addon from AddonManager?

python - 如何在 Ubuntu 10.04 上为 python 3 安装 pycairo

python - 当多个输入同时滴答时,如何防止 combine_latest 多次触发?