Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Created October 9, 2015 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdlrobson/99b0ea3c1c9e05e181c1 to your computer and use it in GitHub Desktop.
Save jdlrobson/99b0ea3c1c9e05e181c1 to your computer and use it in GitHub Desktop.
File for generating a job using api on Webpagetest.org
var WebPageTest = require('webpagetest');
var url = 'http://wikipedia.org/';
var tLocation = 'Dulles.2G';
var key = 'YourKey';
var wbtInstance = 'http://www.webpagetest.org/';
var wpt = new WebPageTest( wbtInstance, key );
wpt.runTest(url, {
runs: 9,
firstViewOnly: true,
connectivity: '2G',
location: tLocation
}, function(err, data) {
if ( err ) {
console.log( 'ERROR: ' + err );
} else if ( data.statusCode !== 200 ) {
console.log( 'ERROR: ' + data.statusCode );
} else {
try{
console.log( data.data.jsonUrl );
} catch( e) {
console.log( 'ERROR:', data );
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment