Python Webdriver不在Windows上加载页面 [英] Python Webdriver not loading page on Windows

查看:219
本文介绍了Python Webdriver不在Windows上加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows电脑上使用Python 3.5。当我在我的Mac上运行这个代码时,它是完美的,没有任何问题。但是,当我把代码带到我的Windows电脑上时,它不起作用。

基本上,Web浏览器将会打开,但是我只是得到一个空白页面。什么都不会加载,甚至没有主页。

pre $ 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



确保你已经安装了最新的beta版本(selenium-3.0.0b2)if你使用geckodriver v0.10.0及以上版本:

  pip install -U selenium --pre 

code>

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


I am using Python 3.5 on a Windows computer. When I run this code on my Mac it works perfect, no issues what so ever. But when I bring the code to my Windows computer it doesn't work.

Basically the web browser will open but I will just get a blank page. Nothing will load, not even 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:

"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? 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:

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:

pip install -U selenium --pre

Note that you need the --pre flag to install the beta version.

这篇关于Python Webdriver不在Windows上加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆