Skip to content

Instantly share code, notes, and snippets.

@SteveBarnett
Last active April 14, 2016 07:00
Show Gist options
  • Save SteveBarnett/0ed7446c49b8e0c965d0 to your computer and use it in GitHub Desktop.
Save SteveBarnett/0ed7446c49b8e0c965d0 to your computer and use it in GitHub Desktop.
Current preferred WebPageTest setup

Run using the excellent WebPageTest API wrapper for NodeJS by Marcel Duran, and $WPT_API_KEY as an environment variable.

Command

webpagetest test example.com -k $WPT_API_KEY -l "Dulles_MotoG" -y "custom" -D 100 -U 100 -Y 200 -r "5" -vpt

-k key -l location and device (Dulles being thinly place with a selection of mobile devices, at the time of writing) -y network -D download bandwidth. -U upload bandwidth -Y latency -r runs -v capture video -p private (don't include in WPT log) -t sensitive (discard headers and the script in the result)

Download bandwith is set to 100 and latency to 200 to mimic very harsh consistent but slow connectivity on 2G.

A less harsh version for a 3G connection:

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

Command for behind a log in

Ditch the location because scripting only works for Chrome (at the time of writing).

Scripting

setValue fills in the form data, targetted with attribute=value submitForm submits the form, targetted with attribute=value

// Stop recording
logData 0
// bring up the login screen
navigate example.com
// Start recording
logData 1
// log in
setValue name=username USERNAME
setValue name=password PASSWORD
submitForm name=login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment