2

I'm having great difficulties creating two instances of firefox via marionette. Having one instance works fine:

Starting up Firefox with marionette enabled:

firefox.exe -marionette

Controlling it with python:

from marionette import Marionette
client = Marionette('localhost', port=2828)
client.start_session()
client.execute_script("alert('o hai there!');")

Now I'd like to add a second client alongside the current one, a quick search resulted in the --address command:

firefox.exe -marionette --address=localhost:2829

Trying to control it via python:

from marionette import Marionette
client = Marionette('localhost', port=2829)
client.start_session()
client.execute_script("alert('o hai there!');")

I can't seem to get this to work, however:

error: [Errno 10061] No connection could be made because the target machine actively refused it

Any help is greatly appreciated.

4

1 回答 1

5

您必须使用不同的配置文件来让 firefox 监听不同的端口。
编辑<path-to-profile>/prefs.js添加以下内容并在 Firefox 不使用此配置文件时保存;

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

于 2016-06-06T20:15:27.700 回答