Gathering page load performance metrics using Selenium

Performance measure using selenium :


Automating YSlow score using webpagetest, yslow command line and node js

The following is the sequence to generate the YSLOW score using script.

1. Create the environment

  • Install node js on RHEL :
    sudo yum localinstall --nogpgcheck nodejs-stable-release.noarch.rpm
    sudo yum install nodejs-compat-symlinks npm
  • Install YSlow commandline as explained in
    sudo npm install yslow -g

    The following error is OK

    > contextify@0.1.2 install /usr/lib/node_modules/yslow/node_modules/jsdom/node_modules/contextify
    > node-gyp rebuild
            throw e; // process.nextTick error, or 'error' event on first tick
    Error: Cannot find module '/usr/lib/nodejs/npm/node_modules/node-gyp/bin/node-gyp.js'
        at Function._resolveFilename (module.js:332:11)
        at Function._load (module.js:279:25)
        at Array.0 (module.js:479:10)
        at EventEmitter._tickCallback (node.js:192:40)
    npm WARN optional dependency failed, continuing contextify@0.1.2
    /usr/bin/yslow -> /usr/lib/node_modules/yslow/bin/yslow
    yslow@3.1.0 /usr/lib/node_modules/yslow
    ├── commander@0.5.2
    └── jsdom@0.2.13

2. Get Key for accessing the REST apis

  • Send mail to with the following details
    • Purpose of the use
    • Number of API calls/day

3. Write script to get the HAR file from and generate the Yslow file

Notes :

Automating the YSLOW score and HAR using Firefox plugins(NetExport,YSlow)

I have used the following url as source for my experiment.

Goal : To automate the following

1. To get YSLOW score of  a webpage

2. To get the Http Archive (HAR) of a webpage

Steps followed

1. Setup firefox with a new profile ‘PerformanceTest’.

  • Create a new profile(In Mac) : /Applications/ -P

2. Install the firebug, yslow and netexport plugins into this profile.

3. Create a web application URL to accept the YSLOW and HAR data

  • On mac(using default apache webserver) , create the Perl CGI scripts  under folder /Library/WebServer/CGI-Executables
  • Scrpt
  • #!/usr/bin/perl -wprint "Content-type: text/html\n\n";
    open FILE, '>/tmp/yslow.txt';
    #print "<pre>\n";if ($ENV{'REQUEST_METHOD'} eq "GET") {$request = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $request,$ENV{'CONTENT_LENGTH'})
    || die "Could not get query\n";
    foreach $key (sort keys(%ENV)) {
    print FILE "$key = $ENV{$key}\n";
    print FILE $request;
    close FILE;


  • script
  • #!/usr/bin/perl -wprint "Content-type: text/html\n\n";
    open FILE, '>/tmp/har.txt';
    #print "<pre>\n";if ($ENV{'REQUEST_METHOD'} eq "GET") {$request = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $request,$ENV{'CONTENT_LENGTH'})
    || die "Could not get query\n";
    foreach $key (sort keys(%ENV)) {
    # print FILE "$key = $ENV{$key}\n";
    print FILE $request;
    close FILE;

4. In firefox set the following plugin values

  • extensions.yslow.beaconUrl=
  • extensions.yslow.autorun=true
  • extensions.firebug.netexport.beaconServerURL=
  • extensions.firebug.netexport.autoExportToServer=true
  • extensions.firebug.netexport.alwaysEnableAutoExport=true
  • In the browser firebug panel, set the ‘AutoExport’ to on.
  • You can also set the send to URL using this panel , in the screenshot you could see that the data is sent to

5. Run the firefox from the command line as following. This will generate the files ‘/tmp/yslow.txt’ and ‘/tmp/har.txt’ containing YSLOW and HAR data for that page.

6. Now you can keep this command in your shell/perl script for executing as automated. For example the following script

  • #!/bin/bashFIREFOX="/cygdrive/c/Program Files/Mozilla Firefox/"
    for link in `echo $URLS`;
    firefox.exe -P yslow -no-remote $link &
    sleep 20
    kill $PID

6. Thanks.