简体   繁体   English

在 Python Selenium 中为 Firefox 设置配置文件和二进制文件不会打开浏览器

[英]Setting up a profile and binary for Firefox in Python Selenium won't open a browser

As the title says when i set a profile and binary and then input them into webdriver.Firefox, no browser is open.正如标题所说,当我设置配置文件和二进制文件然后将它们输入 webdriver.Firefox 时,没有打开浏览器。 I have looked for hours and found no ways to solve this.我已经找了几个小时,没有找到解决这个问题的方法。 Any help would be appreciated.任何帮助,将不胜感激。

Code I've tried:我试过的代码:

binary = FirefoxBinary("D:\\Program Files\\Mozilla Firefox\\firefox.exe")
profile = FirefoxProfile("D:\\SYC\\fireFox\\Project\\lp5w3va5.PythonBot")
driver = webdriver.Firefox(profile, binary)
binary = FirefoxBinary("D:\\Program Files\\Mozilla Firefox\\firefox.exe")
profile = FirefoxProfile("D:\\SYC\\fireFox\\Project\\lp5w3va5.PythonBot")
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary)
binary = FirefoxBinary("D:\\Program Files\\Mozilla Firefox\\firefox.exe")
profile = FirefoxProfile("D:\\SYC\\fireFox\\Project\\lp5w3va5.PythonBot")
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, executable_path="D:\\Python\\geckodriver.exe")

Running this code (even with driver.get) will not display any webbrowser.运行此代码(即使使用 driver.get)将不会显示任何网络浏览器。 I do not get any errors when compiling this code.编译此代码时我没有收到任何错误。 I am honestly just stuck on how I can get this to work,老实说,我只是坚持如何让这个工作,

Doing正在做

driver = webdriver.Firefox()

will start up a browser with a temp profile with no settings (each time I run the script, a different temp profile is created).将使用没有设置的临时配置文件启动浏览器(每次运行脚本时,都会创建一个不同的临时配置文件)。

Any ideas on why this is happening?关于为什么会发生这种情况的任何想法?

Edit: For clarification, I have geckodriver install in my python folder.编辑:为澄清起见,我在 python 文件夹中安装了 geckodriver。 Running a web browser with a profile works perfectly fine.使用配置文件运行 web 浏览器可以正常工作。

Edit: Solved it.编辑:解决了。 The problem was that putting the profile in my D: drive created a remote dir, but I needed a local dir.问题是将配置文件放在我的 D: 驱动器中创建了一个远程目录,但我需要一个本地目录。 Which I had to put my profile with my other profiles in my C: Drive我必须将我的个人资料与其他个人资料一起放在我的 C 中:驱动器

try to download mozilla driver Drivers尝试下载 Mozilla 驱动程序

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

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