-
Notifications
You must be signed in to change notification settings - Fork 30
If you haven't already, read the README get an overview and examples of the concepts used in this page.
To use Queen, you'll need Node.js 0.8 or higher.
There are two distinct way Queen operates. As a HTTP server which captures browsers, and as a TCP server for applications to execute code on captured browsers. The second server is optional if you're only using Queen locally, but Queen is intended to be used as browser pool for your entire organization to execute code on.
The easiest way to test and play around with Queen is to start the Queen and run a script in one step
by executing something like queen your-script.js
, and then connecting a browser. While
this is easy, it's inefficient. This means you have to stop and start a Queen Server whenever you
want to run a script.
So, let's separate out the process to two parts:
- Start the Queen Server
- Execute code on the Queen Server
- Execute:
queen -h localhost:9101 -c localhost:9200
-
-h localhost:9101
tells Queen to capture browsers at http://localhost:9101. If we didn't give queen this option, it would capture browsers at [your ip address]:80. Queen will log out to the console which host it's capturing browsers when it starts. -
-c localhost:9200
tells Queen to listen for TCP connections at localhost:9200, this is where other applications can connect to in order to run scripts on the browsers Queen has captured. - Since we didn't provide a filename, Queen won't try to run a script, it's now just acting as a pure server. Also note that if there is a queenConfig.js file in the directory queen is started in, Queen will use those options to initialize itself.
-
- Point one or more browsers at http://localhost:9101
- This allows Queen to "capture the browsers". Once it has successfully captured the browser, it'll be able to push scripts to the browser for it to run.
- Execute:
queen -r localhost:9200 http://queenjs.com/server-example.js
-
-r localhost:9200
tells Queen to run in "remote" mode and connect to a Queen server running at localhost:9200, which is the Queen Server we started in step 1. -
http://queenjs.com/server-example.js
is the queen script we want to execute. It will ask the Queen server to runhttp://queenjs.com/client-example.js
on captured browsers, this Queen will then established socketed communication between the server-example.js script running on your machine and the many client-example.js scripts running on the browsers.
-
You can use Queen in three ways
Install queen by executing npm install -g queen
in your command line.
Queen can be executed through the command line as queen [options] [filepath]
.
The only thing you cannot configure through the command line is populators, you'll need a
queenConfig.js file in order to define those.
When queen is started without a server-side script, it will act as a hub for remote clients to connect to and execute their server-side scripts. See the queen-remote project for more information on the remote client.
Queen can be require
'd in to your project as a module, allowing you to run queen programatically,
or extend it to suit your needs.