我很难通过木偶创建两个firefox实例。有一个实例很好:
启用木偶启动Firefox:
firefox.exe -marionette
用python控制它:
from marionette import Marionette
client = Marionette('localhost', port=2828)
client.start_session()
client.execute_script("alert('o hai there!');")
现在,我想在当前客户机的旁边添加第二个客户机,快速搜索生成--address命令:
firefox.exe -marionette --address=localhost:2829
试图通过python控制它:
from marionette import Marionette
client = Marionette('localhost', port=2829)
client.start_session()
client.execute_script("alert('o hai there!');")
然而,我似乎无法让它发挥作用:
error: [Errno 10061] No connection could be made because the target machine actively refused it
任何帮助都是非常感谢的。
发布于 2016-06-06 20:15:27
您必须使用不同的配置文件来让firefox在不同的端口上监听。
编辑<path-to-profile>/prefs.js
,添加以下内容,并在火狐不使用此配置文件时保存;
user_pref("marionette.defaultPrefs.port", 2829);
现在,启动firefox;
firefox -marionette --profile <path-to-profile> --new-instance&
建立新的形象;
$ mkdir new_profile
$ firefox --profile new_profile --new-instance
关闭火狐。现在你有new_profile/prefs.js
了
发布于 2022-08-26 13:00:46
上一次回复已经有一段时间了,所以更新一下
目前(火狐版本103+)首选项必须设置为
marionette.port
所以,你必须设置
user_pref("marionette.port", 2829);
所有程序看起来都是:
$ firefox -CreateProfile "p2829 /tmp/ff_p2829"
$ vi /tmp/ff_p2829/prefs.js #new file
> enter user_pref("marionette.port", 2829);
$ firefox -marionette -profile /tmp/ff_p2829/ -new-instance
现在火狐木偶服务器正在监听端口2829
https://stackoverflow.com/questions/37514778
复制相似问题