Skip to content

Command Line Options

Mark Watson edited this page Aug 5, 2016 · 5 revisions
script-editor [options] [filename]

  -console / -c   start on the console (no gui)
  -har            save a HTTP Archive file after running console script
  -help / -h      print this help
  -version / -v   print the version number

Run a Script

To run a script without bringing up the editor window:

bin/script-editor -console scripts/google.js

If the script fails the command will exit with a status code of 1 and the error will be printed to . E.g.

TypeError: Cannot find function doesNotExist

Details of all the pages and HTTP items downloaded can be saved off into a Http Archive file. To save a HAR file specify the -har option:

bin/script-editor -console scripts/google.js -har

The file is saved to the same file path as the script was loaded from, but with .har appended, in this case: scripts/google.js.har

Open File in the Editor

bin/script-editor scripts/google.js

A new editor will be launched each time.

Open Scripting Console

If you don't want to open the editor, but still want to control the browser interactively you can type the following:

bin/script-editor -console
>> var b = pizza.open("www.google.com")
Launched Chrome version 51.0.2704.103
>> b.query("input[name='q']")
[
  {
    "path": "#lst-ib",
    "visible": true,
    "pos": {
      "top": 328,
      "left": 291.5,
      "width": 425,
      "height": 26
    },
    "attributes": {
      "aria-autocomplete": "both",
      "role": "combobox",
      "autocomplete": "off",
      "maxlength": "2048",
      "aria-haspopup": "false",
      "dir": "ltr",
      "title": "Search",
      "type": "text",
      "spellcheck": "false",
      "name": "q",
      "id": "lst-ib",
      "class": "gsfi lst-d-f",
      "value": "",
      "aria-label": "Search"
    },
    "tag": "input",
    "zIndex": "6"
  }
]
>> b.close();
Closing Chrome...
>> exit()

This can be useful if you want to run the browser headless, or only have SSH access to a machine.

Clone this wiki locally