Performance Testing using Selenium Webdriver



Yes we know that Selenium Webdriver is a functional testing tool and is not a recommended option to do performance! But then there are times that you want to just do a quick performance check and find the bottlenecks in your application, here is how:

The solutions here are organised based on the complexity and detail you want to achieve:

Solution 1:  Measuring performance using a Timer in Selenium WebDriver

We can use the the StopWatch class for measuring the time taken for the page to load or any inbuilt date time calendar feature:


StopWatch pageLoad = new StopWatch();
pageLoad.start();
//Perform your test
pageLoad.stop();
System.out.println("Total Page Load Time: " + pageLoad.getTime() + "milliseconds");

Or

Calendar cal = Calendar.getInstance();
Date d1 = cal.getTime();
//Perform your test
Calendar cal2 = Calendar.getInstance();
Date d2 = cal2.getTime();
long diff = d2.getTime() - d1.getTime();
long diffSeconds = diff / 1000 % 60;  
long diffMinutes = diff / (60 * 1000) % 60;   
System.out.println("Execution Time:",diffMinutes+" minute and "+diffSeconds+"seconds"););

Solution 2:  Measuring performance with the Navigation Timing API

JavascriptExecutor js = (JavascriptExecutor) driver;
long navigationStart = (Long) js.executeScript("return window.performance.timing.navigationStart;");
//Perform your test
long loadEventEnd = (Long) js.executeScript("return window.performance.timing.loadEventEnd;");
System.out.println("Page Load Time is " + (loadEventEnd - navigationStart)/1000 + " seconds.");

Solution 3:  Measuring performance with JMeter
http://seleniummaster.com/sitecontent/index.php/performance-test-menu/selenium-load-test-menu

Solution 4:  Measuring performance with Firebug's Net panel
http://www.softwareishard.com/blog/firebug/automate-page-load-performance-testing-with-firebug-and-selenium/


Hope that helps someone playing with Selenium WebDriver and trying to achieve some basic performance testing!

Comments

  1. Thank you so much for this nice information. Hope so many people will get aware of this and useful as well. And please keep update like this.

    Game QA Solutions

    PC Game Testing Services

    ReplyDelete
  2. Great!! Thank you for sharing this post on software testing. Software testing outsourcing services are in great demand these days. Good to see such nice articulated post.

    ReplyDelete
  3. Thanks for sharing,this blog makes me to learn new thinks.
    interesting to read and understand.keep updating it.
    call girls in dehradun
    escort service in dehradun

    ReplyDelete


  4. Thanks for sharing,this blog makes me to learn new thinks.
    interesting to read and understand.keep updating it.
    call girls in ghaziabad
    escort service in ghaziabad

    ReplyDelete

  5. Thanks for sharing,this blog makes me to learn new thinks.
    interesting to read and understand.keep updating it.
    call girls in gurgaon
    escort service in gurgaon

    ReplyDelete
  6. Great post, Selenium is an open-source, test automation tool that has become an important automation tool in the software quality assurance world. This selenium testing tool consists of a different set of tools which include Selenium WebDriver, Selenium RC, Selenium IDE, and Selenium Grid, all of which have different features. Selenium testing tool is a lightweight tool and is developer-friendly, commonly used for automating web applications.

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?