在 python 中使用带有 selenium webdriver 的默认 firefox 配置文件 [英] Using the default firefox profile with selenium webdriver in python
问题描述
我知道以前有人问过类似的问题,但我试了很多次,但它仍然不适合我.
I know similar questions have been asked before, but I've tried many times and it still doesn't work for me.
我在 Firefox 中只有一个默认配置文件(称为 c1r3g2wi.default),没有其他配置文件.当我使用 selenium webdriver 启动它时,我希望我的 firefox 浏览器以这个配置文件开始.我如何在 Python 中执行此操作?
I only have a default profile in firefox (called c1r3g2wi.default) and no other profiles. I want my firefox browser to start with this profile when I launch it using the selenium webdriver. How do I do this in Python?
我是这样做的:
fp = webdriver.FirefoxProfile('C:\Users\admin\AppData\Roaming\Mozilla\Firefox\Profiles\c1r3g2wi.default')
browser = webdriver.Firefox(fp)
但是我遇到了一个错误:
But I got an error:
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect:
'C:\\Users\x07dmin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\c1r3g2wi.default/*.*'
非常感谢帮助或正确方向的指示.
Help, or pointers in the right direction, would be very much appreciated.
推荐答案
好的,我只是通过将文件路径中的所有斜杠从\"更改为/"来解决这个问题.从来不知道这会有所作为.
Ok, I just solved this by simply changing all the slashes in my file path from "\" to "/". Never knew this would make a difference.
C:/Users/admin/AppData/Roaming/Mozilla/Firefox/Profiles/c1r3g2wi.default
这篇关于在 python 中使用带有 selenium webdriver 的默认 firefox 配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!