This article will guide you through how to use SpeedCurve to test pages that require authentication. This will be done using WebPagetest scripts - you can read about how to add scripts here: Adding WebPagetest scripts to URLs.

Below are some example scripts that authenticate the browser session in different ways. They have been annotated with comments to explain what each step is doing, and you can find more information about scripting in the WebPagetest scripting documentation.

Important:  WebPagetest scripts are tab-delimited. When pasting the example scripts into the script editor, take care to replace any spaces between commands and arguments with tabs.

Submitting a login form

// Turn data logging off to ensure that performance metrics are only recorded
// after we've logged in.
logData 0

// Navigate to the login page
navigate https://speedcurve.com/

// SpeedCurve's login is a modal popup, so click on the "Log In" link and wait
// for the modal to open.
click id=link-login
sleep 1

// Fill in the login form fields and click the button to log in.
setValue id=loginEmail test-user@speedcurve.com
setValue id=loginPassword testpassword
clickAndWait id=loginButton

// Clear the page so that WebPagetest's visual analysis can start with a blank page
execAndWait document.body.innerHTML = ''

// Turn data logging back on and navigate to a page that requires authentication
logData 1
navigate https://speedcurve.com/speedcurve/speedcurve/site/?b=apple-iphone-6-plus&d=90&de=1&ds=1&r=us-west-1&s=1&u=11833

Note that the commands like setValue and click all work by running JavaScript on the page. If you have any issues using those commands or if you prefer to have more control over the page interaction, you can write the JavaScript yourself by using the execAndWait command. For example, the script above could be modified to fill in the form with JavaScript:

execAndWait	document.querySelector('#loginEmail').value = 'test-user@speedcurve.com'
execAndWait document.querySelector('#loginPassword').value = 'testpassword'
execAndWait document.querySelector('#loginButton').click()

Setting authentication cookies

// Set a cookie on the root speedcurve.com path
setCookie https://speedcurve.com/ userid=xxxxxxxxxxxx

// Navigate to the page that requires authentication
navigate https://speedcurve.com/speedcurve/speedcurve/site/?b=apple-iphone-6-plus&d=90&de=1&ds=1&r=us-west-1&s=1&u=11833

Setting authentication headers

// Set a cookie on the root speedcurve.com path
setCookie https://speedcurve.com/ userid=xxxxxxxxxxxx

// Navigate to the page that requires authentication
navigate https://speedcurve.com/speedcurve/speedcurve/site/?b=apple-iphone-6-plus&d=90&de=1&ds=1&r=us-west-1&s=1&u=11833
Did this answer your question?