Skip to content

Instantly share code, notes, and snippets.

@SteveBarnett
Last active November 12, 2017 21:32
Show Gist options
  • Save SteveBarnett/b3ef5f9b3d2af696d65f to your computer and use it in GitHub Desktop.
Save SteveBarnett/b3ef5f9b3d2af696d65f to your computer and use it in GitHub Desktop.
Boilerplate for running WebPageTest from the command line, using the WebPageTest API Wrapper for NodeJS

npm install webpagetest -g


webpagetest test wpt-script.txt -k $WPT_API_KEY -l "Dulles_MotoG" -y "3G" -r "5" -vpt


This ^^^ does 5 runs of the test on a Motorola Moto G on a 3G connection. If you're feeling brave, try -y "3GSlow". If you're feeling really brave, try -y Edge.

  • -k for key
  • -l for location
  • -y for connection
  • -r for runs
  • -v for video
  • -p for private (keep the test hidden from the test log)
  • -t for sensitive (discard script and http headers in the result, for when you include logins and such in the script)
// Don't record: we only want stuff after log in
logData 0
navigate http://example.com
// set values in inputs
setValue name=username user
// Then submit the form
submitForm id=login
// Start recording
logData 1
navigate http://example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment