如何在当前 window 会话中 运行 selenium python 脚本?

How to run selenium python script in current window session?

当我编写 selenium python 脚本时,我必须使用

之类的命令启动会话
driver = webdriver.Firefox()

但是,这会打开一个新的浏览器 window。

我想要的是让脚本访问已经打开的 window,就像我启动了 selenium IDE 附加组件(不能运行 python 脚本 afaik)。

谁能告诉我是否有办法做到这一点?

我经常想要使用 Selenium 和 Python 我自己的这个功能。不幸的是,它不是 Selenium 当前功能的一部分。

有关详细信息,请在此处查看答案主题:

Can Selenium interact with an existing browser session?

(貌似有人想出了一个 hack 解决方案,但我还没有测试过)

这里:

Can Selenium webdriver attach to already open browser window?

祝你好运!