简体   繁体   English

我该如何使Selenium使用我的firefox(而不是创建新的)

[英]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 headersaotuproxy 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.

相关问题 如何设置Selenium以使用多个Firefox配置文件? - How can I set up Selenium to use multiple Firefox profiles? 如何在套件中的测试类中共享一个webdriver实例?我使用Selenium2和Python - How can I share one webdriver instance in my test classes in the suite? I use Selenium2 and Python 我如何通过Python Selenium在多个firefox二进制文件中选择要使用的firefox可执行文件 - How can I choose which firefox executable to use among multiple firefox binaries through Python selenium 如何在旧的 Firefox 版本 (Firefox 47) 上使用 Selenium 4.7.2 (Python)? - How can I use Selenium 4.7.2 (Python) on an old Firefox version (Firefox 47)? 如何用selenium在firefox中禁用javascript? - How can I disable javascript in firefox with selenium? 如何使我的 python selenium 项目在 heroku 上工作 - how can I make my python selenium project work on heroku 如何使用 GeckoDriver 和 Firefox 到 Python 检测不到 Selenium 脚本? - How can I make a Selenium script undetectable using GeckoDriver and Firefox through Python? 如何防止在浏览网站期间更改我的 ip - How I can prevent to change my ip during browse the website by usening selenium pyhthon firefox 如何将 cookies 保存到 Selenium Python 中的 Firefox 配置文件中,然后在接下来的 session 中再次加载它们? - How can I save cookies to my Firefox Profile in Selenium Python and load them in again next session? 如何在普通浏览器中使用硒 - how can I use selenium with my normal browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM