WebDriver/Marionette/Setup

From MozillaWiki
Jump to: navigation, search

Running B2G and Marionette on an emulator

To run B2G with Marionette on an emulator, clone the latest B2G code:

 git clone git://github.com/andreasgal/B2G.git


Make sure you have all the necessary pre-requisites. Then do the following (the make steps will take time):

 cd B2G
 make sync
 make config-qemu
 make gonk
 make
 ./emu.sh

An emulator with Marionette running inside has now launched!

Using a running emulator

If you are already running an emulator, you can still run these tests. To do so, please remember to forward the port:

 adb forward tcp:2828 tcp:2828

You can now talk to marionette on port 2828 of localhost.

Debugging the emulator

It's a big PITA to debug things on the emulator. I've added some logging code (inspired by ctalbert) which you can use to write things to a log file. To use it, you can do this from JS code:

 Cu.import("resource:///modules/marionette-logger.jsm");
 MarionetteLogger.write('some message');

To view the log, do this, while the emulator is running:

 $B2G_HOME/glue/gonk/out/host/linux-x86/bin/adb shell cat /data/marionette.log

If 'marionette.log' already exists when the emulator is launched, a marionette-1.log will be created, and so forth.

Running Marionette on Desktop Firefox

To run Marionette in Firefox, make sure you have the environment ready for building firefox. Once you're at the stage of configuring and building firefox, you can follow these steps:

At the top of your mozilla-central tree, create an hg patch queue:

 hg qinit

Navigate to $(m-c)/.hg/patches and clone the marionette code

 cd $(m-c)/.hg/patches
 hg clone http://hg.mozilla.org/users/mdas_mozilla.com/marionette-pq .

Replace the 'series' file with the 'series-add-rd' file (Note for the curious: the 'series' file that is included in the repo is for patching the remote-debug branch of m-c, not for m-c actual):

 cp series-add-rd series

and then apply all the patches to m-c:

 cd ../../
 hg qpush -a

Once all the patches are successfully applied, you may now configure and build:

 make -f client.mk config
 make -f client.mk build

The Firefox build in your object-directory now has Marionette installed. If you launch it, then Marionette will be listening on localhost:2828.

Communicating with the Server

You can use our client to talk to the Marionette server.

The server responds to our JSON wire protocol, so you can follow this protocol if you wish to set up your own client.