Webdriver.get(url)打开Firefox,但不打开URL [英] Webdriver.get(url) open Firefox but not the URL

查看:593
本文介绍了Webdriver.get(url)打开Firefox,但不打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Python中使用以下代码:

I am using this code in Python:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)
driver.get("www.google.com")

不幸的是,这将打开Firefox,但不会打开URL(不返回任何错误). 你知道为什么吗?

Unlucky, this open Firefox but not the URL (not return any error). Do you know why?

推荐答案

如果您将 Selenium 3.x 与最近的 Frirefox Quantum 浏览器一起使用,则必须从此位置下载 geckodriver.exe 并将其放置在系统中,然后通过参数 executable_path 提及 geckodriver 二进制文件的绝对位置,如下所示:

If you are using Selenium 3.x along with the recent Frirefox Quantum browsers, you have to download geckodriver.exe from this location place it in your system and mention the absolute location of the geckodriver binary through the argument executable_path as follows:

from selenium import webdriver

driver = webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()

这篇关于Webdriver.get(url)打开Firefox,但不打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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