[英]How can I make Selenium use my firefox (not create a fresh one)
I am new to selenium. 我是硒新手。
I found selenium would not use my local firefox browser. 我发现硒不会使用本地的Firefox浏览器。 Seems it create a fresh one with no plugin. 似乎可以创建一个没有插件的全新插件。
But I want do something with plugin on, such as: modify request headers
, aotuproxy
. 但是我想在插件上做一些事情,例如: modify request headers
, aotuproxy
。 I only found setting headers example in java. 我只在Java中找到设置标头示例。
Though proxy can be set by using webdriver.FirefoxProfile().set_preference('network.proxy.http',....
, it is not so sweet to fit my aim. 尽管可以使用webdriver.FirefoxProfile().set_preference('network.proxy.http',....
来设置代理,但它并不适合我的目标。
So I think it would be very nice to make selenium use my firefox. 因此,我认为让硒使用我的Firefox非常好。 But I can not figure it out. 但是我无法弄清楚。
Selenium cannot connect to an existing browser. Selenium无法连接到现有浏览器。 It can only launch new instances. 它只能启动新实例。
Ok, I find the answer.Give a profile path is the point. 好的,我找到答案了。
def get_ffprofile():
ff_profile_path = 'C:\\Users\\Kasim\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\my89fce2.default'
ff_profile = webdriver.FirefoxProfile(ff_profile_path)
return ff_profile
then 然后
browser = webdriver.Firefox(firefox_profile=get_ffprofile())
Will start my browser(actually a browser instance with my custom profile in another word) 将启动我的浏览器(实际上是使用我的自定义配置文件的浏览器实例)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.