Skip to content

WIP automated testing

Andrea Giammarchi requested to merge puppeteer into release-2019-1

This WIP provides the following CLI API to record an test session, and play it back from the saved session per each build.

#               define the extension path                            test file name                record session
./automation.js --extension ~/gitlab/adblockpluschrome/devenv.chrome --test ~/test/add-filter.json --record

A new browser opens to the current options page. You can start clicking things, add test, move the mouse around, or insert filter. Whenever you have done, close the browser/session.

A new file ~/test/add-filter.json is stored so that to play back the recorder session:

# same as before, *without* --record
./automation.js --extension ~/gitlab/adblockpluschrome/devenv.chrome --test ~/test/add-filter.json

The browser will play back almost everything the user did during the session, replicating expectations.

At the end of the test, a .png file will be created with a screenshot of the last page. The png will have the same name of the tested, and if there was previously a png, it compares the results and shout in console that pngs look different, showing the images generated by such files.

Current Options

Usage: automation [options]

Options:
  -V, --version           output the version number
  -e, --extension <path>  The ABP extension path
  -t, --test <path>       Test test file path
  -r, --record            Record session and output json
  --abp [popup|options]   Optional abp page to test. Default options
  -p, --page [url]        Optional page to visit. Default about:blank
  -w, --width [num]       Optional browser width. Default 1280
  -h, --height [num]      Optional browser height. Default 920
  -s, --sleep [num]       Optional sleep between events. Default 0
  -h, --help              output usage information

Please note the popup page opens but it doesn't really work. Might need some help to be able to simulate the popup opened in a page a part instead of being opened over the current page, but I am not even sure that is possible.

TODO

  • ask "Are you sure?" if --record is used, but that test file already existed (avoid seppuku by copy and paste)
  • more possibilities, including dealing with the popup instead of the options (although this is currently not possible see bug #2486)
Edited by Andrea Giammarchi

Merge request reports