WebPageTest - Beyond The Basics
@AndyDavies
5 Feb 2016
http://webpagetest.org
http://usingwpt.com
Aimed at Novices and Power Users
Includes:
Basics�
Getting started, running tests, understanding waterfall charts and the metrics WebPageTest captures
Intermediate
Picking the right test parameters, scripting multi-page tests and using your existing analytics data to help the decisions
Advanced
Using the API, integrating WebPageTest into build and CI processes, and setting up your own private instances
Video and filmstrip of page loading
Waterfall
Summary metrics
Repeat View - check for effective caching
But what can it do beyond that?
Advanced Settings…
…is a whole another world
Shape network connection
Choose at least 3 runs
Create pcap for Wireshark etc.
Inject custom headers
e.g. Akamai debug
Make tests run for longer
e.g catch slow XHR requests
Chrome only options
Emulate mobile browsers
Capture Chrome debugging info from remote browser
Add command-line options - great for comparing HTTP/1.1 vs HTTP/2
What happens when a 3rd Party Breaks?
Site to check
Host to ‘blackhole’
What’s the impact of 3rd Parties?
Convert the list of domains into a space separated list�(copy ‘n’ paste plus text editor)
Paste list of domains / urls to remove
Doesn’t always go to plan!
But with patience, and by adjusting the block list we can get there http://man.gl/1nLwRZe
Custom Metrics
https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/custom-metrics
Query DOM using JavaScript to create custom measurement
Beyond simple single page tests
Scripting
Searching Google
Searching Google
logData 0
navigate http://google.co.uk
setvalue id=lst-ib akamai
logData 1
submitform id=tsf
Searching Google
Results page only - http://man.gl/1PEEwn4
Search and results page - http://man.gl/1PEEBak
Waterfall for results page only
Use DevTools to identify elements
Sometimes there’s no obvious hook…
How can we target this link?
JavaScript to the rescue!
document.querySelector('.orb-nav-news a')
JavaScript to the Rescue!
Result http://man.gl/1PEGQdL
logData 0
navigate http://www.bbc.co.uk/
logData 1
execAndWait document.querySelector('.orb-nav-newsdotcom a').click();
execAndWait - execute JS and wait for browser to complete activity
exec - execute JS and don’t wait
Debugging scripts can be hard!
navigate http://www.thetrainline.com
logData 0
exec document.getElementById('originStation').value='Cheltenham';
exec $('#originStation').keydown();
exec document.querySelectorAll('#originStation + div + ul > li > a')[0].click();
exec document.getElementById('destinationStation').value='Leeds';
exec $('#destinationStation').keydown();
exec document.querySelectorAll('#destinationStation + div + ul > li > a')[0].click();
exec document.getElementById('isOneWay').checked='checked';
logData 1
execAndWait document.getElementById('submitButton').click();
Script fails due to timing issues
Lots more detail on scripting in the docs:
https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting
Debugging:
Using the API
http://www.webpagetest.org/getkey.php
Works with these public locations
Dulles_IE9 Dulles_IE10 Dulles_IE11 Dulles:Chrome Dulles:Canary Dulles:Firefox Dulles:Firefox Nightly Dulles:Safari Dulles_Chrome40 Dulles_MotoG:Motorola G - Chrome Dulles_MotoG:Motorola G - Chrome Beta Dulles_MotoG:Motorola G - Chrome Dev ec2-us-east-1:Chrome ec2-us-east-1:IE 11 ec2-us-east-1:Firefox ec2-us-east-1:Safari | ec2-us-west-1:Chrome ec2-us-west-1:IE 11 ec2-us-west-1:Firefox ec2-us-west-1:Safari ec2-us-west-2:Chrome ec2-us-west-2:IE 11 ec2-us-west-2:Firefox ec2-us-west-2:Safari ec2-eu-west-1:Chrome ec2-eu-west-1:IE 11 ec2-eu-west-1:Firefox ec2-eu-west-1:Safari ec2-eu-central-1:Chrome ec2-eu-central-1:IE 11 ec2-eu-central-1:Firefox ec2-eu-central-1:Safari | ec2-ap-northeast-1:Chrome ec2-ap-northeast-1:IE 11 ec2-ap-northeast-1:Firefox ec2-ap-northeast-1:Safari ec2-ap-southeast-1:Chrome ec2-ap-southeast-1:IE 11 ec2-ap-southeast-1:Firefox ec2-ap-southeast-1:Safari ec2-ap-southeast-2:Chrome ec2-ap-southeast-2:IE 11 ec2-ap-southeast-2:Firefox ec2-ap-southeast-2:Safari ec2-sa-east-1:Chrome ec2-sa-east-1:IE 11 ec2-sa-east-1:Firefox ec2-sa-east-1:Safari |
Submitting a test
http://www.webpagetest.org/runtest.php?
mv=1&
video=0&
location=Dulles:Chrome&
f=json&
fvonly=1&
k=A.a69f6e28fc64e15b8d330a700f104977&
private=1&
url=http://news.bbc.co.uk
Postman is handy for experimenting with RESTful API http://www.getpostman.com/
Get a response…
{
"statusCode": 200,
"statusText": "Ok",
"data": {
"testId": "160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76",
"ownerKey": "b6a596f5ce4165ef9725bb91d9e4cec75e1f1d8c",
"jsonUrl": "http://www.webpagetest.org/jsonResult.php?test=160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76",
"xmlUrl": "http://www.webpagetest.org/xmlResult/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/",
"userUrl": "http://www.webpagetest.org/result/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/",
"summaryCSV": "http://www.webpagetest.org/result/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/page_data.csv",
"detailCSV": "http://www.webpagetest.org/result/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/requests.csv"
}
}
Poll the JSON or XML URL
| { "data": { "statusCode":100, "statusText":"Test Started 13 seconds ago", "id":"160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76", "testInfo": { "url":"http:\/\/news.bbc.co.uk", "runs":1, "fvonly":1, . . . }, "statusCode":100, "statusText":"Test Started 15 seconds ago" } |
| |
Until the test completes
| { "data": { "id":"160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76", "url":"http:\/\/news.bbc.co.uk", "summary":"http:\/\/www.webpagetest.org\/results.php?test=160205_N4_d2ea71c14d70c68bb0e3d30a88... "testUrl":"http:\/\/news.bbc.co.uk", "location":"Dulles:Chrome", "from":"Dulles, VA - <b>Chrome<\/b> - <b>Cable<\/b>", "connectivity":"Cable", . . . }, "statusCode":200, "statusText":"Test Complete" } |
| |
Data Galore!
Lots more detail on the API in the docs:
https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting
Marcel Duran’s NodeJS API wrapper:
https://github.com/marcelduran/webpagetest-api
Sometimes…
You just want a quick and easy solution…
So how about a spreadsheet?
https://github.com/andydavies/WPT-Bulk-Tester
Demo - http://man.gl/1ocuwqZ
WebPageTest is really great tool
You can use it for quick and simple testing
but…
If you take the time to experiment and learn you can do a whole lot more.
Thanks!
@AndyDavies hello@andydavies.me
P.S. Don’t forget to buy a copy of http://usingwpt.com