Automation scripting with JavaScript and Chrome

| permalink | power user

Why JavaScript

Setting up special Chrome shortcut

You need to disable some security checks to run useful scripts locally, so it's best to setup a shortcut specifically for your script that has the proper options pre-configured.

To do so, create a new shortcut for Chrome.

Open properties and modify the "Target" value to the following (keep existing path to chrome.exe):

"C:\Program Files\Google\Chrome\Application\chrome.exe" file:///C:/Users/JOHNDOE/scripts/mytool.html --allow-file-access-from-files --disable-web-security --user-data-dir="C:/ChromeDevProfile" --test-type

Command line options/switches explained


By default, file:// URIs cannot read other file:// URIs. This is an override for developers who need the old behavior for testing.


Disable CORS (same-origin) restrictions


The previous two flags won't take effect unless you create a separate profile, this specify where it is located (will create if doesn't exist)


Supplying a launch URL, which you should point to your script, or a launch page for your scripts.


Source: [this flag] is basically the 2014 version of --enable-automation

See here and here for more command line switches.