蟒蛇硒导入我的常规Firefox的配置文件(附加组件) [英] python selenium import my regular firefox profile ( add-ons)

查看:186
本文介绍了蟒蛇硒导入我的常规Firefox的配置文件(附加组件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图让我的加载项与我的驱动程序(驱动程序,如webdriver.Firefox(profile))一起工作。我不知道如何导入(或者如果它是可选的)我的常规Firefox配置文件。我假设,包含所有我的附加组件。



确实需要帮助。



解决方案(如果有的话)解释为什么我的附加组件不存在于硒webdriver可能是一个很好的触摸。



非常感谢!!

解决方案

如果您这样做,并将 path_to_my_profile 设置到常规配置文件所在的位置, Selenium应该使用您的配置文件:

  from selenium import webdriver 
from selenium.webdriver.firefox.webdriver import FirefoxProfile
$ b $ profile = FirefoxProfile(path_to_my_profile)
driver = webdriver.Firefox(profile)



我自己并没有这样做,但是我在阅读Selenium代码的基础上这么说。 Selenium默认不使用你的配置文件的原因是默认情况下,使用 None 创建一个 FirefoxProfile 对象作为第一个这意味着为我们即将推出的Firefox实例创建一个新的配置文件。

顺便说一句,Selenium在默认情况下(创建一个新的配置文件)是确保测试重复性的最佳实践。这是一件好事。


I've been trying to get my add-ons to work with my driver(driver as in webdriver.Firefox(profile)). I have no idea how to import (or if its optional at all) my regular Firefox profile. The one, i assume, contains all my add-ons.

Help is needed indeed.

Beside a solution (if available) an explanation to why my add-ons do not exist on the selenium webdriver could be a nice touch.

Thank very much!!

解决方案

If you do this, and set path_to_my_profile to where your usual profile resided, then Selenium should use your profile:

from selenium import webdriver
from selenium.webdriver.firefox.webdriver import FirefoxProfile

profile = FirefoxProfile(path_to_my_profile)
driver = webdriver.Firefox(profile)

I've not done this myself but I say this based on having read the code of Selenium. The reason Selenium does not use your profile by default is that by default a FirefoxProfile object is created with None as the first argument, which means "create a new profile for the Firefox instance we're about to launch".

By the way, what Selenium does by default (creating a new profile) is the best practice to ensure the repeatability of tests. It is a good thing.

这篇关于蟒蛇硒导入我的常规Firefox的配置文件(附加组件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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