用Marionette(更改端口)添加Firefox的第二个实例 [英] Adding second instance of Firefox with Marionette (change port)

查看:949
本文介绍了用Marionette(更改端口)添加Firefox的第二个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过木偶创建两个firefox实例遇到了很大的困难。有一个实例工作正常:

启用启用了木偶的Firefox:

  firefox.exe -marionette 

用python控制它:


$

$ client = Marionette('localhost',port = 2828)
client.start_session()
客户端。 ())

现在我想添加第二个客户端,一个快速搜索导致--address命令:

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

试图通过python控制它:

  from marionette import Marionette 
client = Marionette('localhost',port = 2829)
client.start_session()
client.execute_script(alert('o )

然而,我似乎无法得到这个工作,

 错误:[Errno 10061]由于目标机器主动拒绝连接,因此无法连接

$ b $ p
$ b $ p


$ <$ p $ b $您必须使用不同的配置文件,以使Firefox在不同的端口上侦听。

编辑<路径到配置文件> /prefs.js 添加当firefox不使用这个配置文件时,保存 ;

  user_pref(marionette.defaultPrefs。港口,2829); 

现在,启动firefox为;

  firefox -marionette --profile< path-to-profile> --new实例&安培; 

创建新的个人资料;

  $ mkdir new_profile 
$ firefox --profile new_profile --new-instance

并关闭Firefox。现在你将有 new_profile / prefs.js


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.

解决方案

You have to use different profiles to make firefox listen on different ports.
Edit <path-to-profile>/prefs.js add the following and save when firefox is not using this profile;

user_pref("marionette.defaultPrefs.port", 2829);

Now, start firefox as;

firefox -marionette --profile <path-to-profile> --new-instance&

To create a new profile;

$ mkdir new_profile
$ firefox --profile new_profile --new-instance

and close firefox. Now you'll have new_profile/prefs.js

这篇关于用Marionette(更改端口)添加Firefox的第二个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆