简体   繁体   English

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

[英]Page is not loaded in Selenium WebDriver using Python on Windows

I am using Python 3.5 on a Windows computer.我在 Windows 计算机上使用 Python 3.5。 When I run this code on my Mac it works perfect, no issues what so ever.当我在 Mac 上运行此代码时,它运行良好,没有任何问题。 But when I bring the code to my Windows computer it doesn't work.但是当我将代码带到我的 Windows 计算机时它不起作用。

Basically a blank page is shown instead of the home page.基本上显示一个空白页面而不是主页。 I don't get any error messages.我没有收到任何错误消息。

from selenium import webdriver

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

print(cookies)

Once I close the web browser I get this message in the shell:关闭 Web 浏览器后,我会在 shell 中收到此消息:

"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.

From what I've been able to find online (most is for Java) it looks like I may need to setup a profile?从我在网上找到的内容(大多数是针对 Java 的)看来我可能需要设置一个配置文件? Is this correct and could anyone help with this?这是正确的,有人可以帮忙吗?

It looks like your client doesn't have the fix for the new switch to launch the gecko driver:看起来您的客户没有修复用于启动 Gecko 驱动程序的新开关:

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

Make sure that you have the latest beta version installed (selenium-3.0.0b2) if you which to use the geckodriver v0.10.0 and above:如果要使用 geckodriver v0.10.0 及更高版本,请确保安装了最新的测试版 (selenium-3.0.0b2):

pip install -U selenium --pre

Note that you need the --pre flag to install the beta version.请注意,您需要--pre标志来安装测试版。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM