python selenium 不打开浏览器_Selenium打开浏览器,但不加载页面

在Windows 8.1上使用Python 3.5和Selenium 3.0.1时,遇到浏览器打开但无法加载任何页面的错误。问题在于geckodriver的配置。解决方案包括将geckodriver添加到系统PATH,更新到最新版本(0.11.1),并使用指定的Firefox二进制路径启动Selenium会话。
摘要由CSDN通过智能技术生成

1586010002-jmsa.png

this is an extension from a previous post I made Here which I could not get to work but I am now getting a new error after updating Selenium.

I am using Python 3.5, Windows 8.1, Selenium 3.0.1

I know the code works because it works on my MAC, but when I bring it over to my work computer which is described above, the only thing that happens is the browser will open but it wont load anything, not even a homepage.

From everything I could find on search I downloaded the geckodriver, renamed it to wires.exe and I added the directory to the system PATH.

Untitled1.jpg

I am completely lost on what to do to get this to work. Here is the code im using:

from selenium import webdriver

driver = webdriver.Firefox()

driver.get('https://www.google.com')

Here are the errors I am getting:

Untitled2.jpg

解决方案

I did not add geckodriver to PATH (it is located in the same directory as Python script), and after selenium update to 3.0.1 use this code to start selenium session:

gecko = os.path.normpath(os.path.join(os.path.dirname(__file__), 'geckodriver'))

binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')

driver = webdriver.Firefox(firefox_binary=binary, executable_path=gecko+'.exe')

Additionally: you need update geckodriver to the latest version 0.11.1.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值