python - Webdriver.get(url) 打开 Firefox 但不打开 URL

标签 python selenium firefox webdriver surf

我在 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(不返回任何错误)。 你知道为什么吗?

最佳答案

如果您使用 Selenium 3.x 以及最新的 Frirefox Quantum 浏览器,则必须从 this location 下载 geckodriver.exe将其放入您的系统中,并通过参数 executable_path 提及 geckodriver 二进制文件的绝对位置,如下所示:

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()

关于python - Webdriver.get(url) 打开 Firefox 但不打开 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48045412/

相关文章:

Python 计数函数在教程视频中没有增加

javascript - 在 testdata.properties 文件中显示非英语语言

c# - 无法使用 NUnit、C# 将 Selenium 元素滚动到 View : (34).

azure - Selenium 和 Azure Web 应用程序

javascript - 使用javascript将html插入另一个页面?

python - 在 Django 模板中添加两个变量?

python - 序列化器 - Django REST 框架(AttributeError : Got AttributeError when attempting to get a value for field `user` on serializer)

python - Python 中的 float ('inf' ) 有什么意义?

html - FF 中的 css 显示问题

javascript - 数字时钟在 FireFox 中不工作