Description
This extension adds command 'timerStart' and 'timerStop' . These can be used to calculate the response time for a call or how long a particular element/page takes to download. It takes a name as argument to distinguish between different timers. Time is displayed in 'millisecond'
Code to add to the user-extensions:
user-extensions.js
var globalTime = new Object(); Selenium.prototype.doTimerStart = function(target) { var dt1 = new Date(); if (target == null || target == "") { LOG.info ("Target not present so timer was not started"); } else { globalTime[target] = dt1; } delete dt1; }; Selenium.prototype.doTimerStop = function(target) { var dt = new Date(); if (target == null || target == "") { LOG.info ("Please specify a target"); } else if (globalTime [target] == null) { LOG.info ("Start time was not called for " + target); } else { LOG.info ("Time Passed for " + target + " : " + Math.floor (dt - globalTime[target])); storedVars[target]=Math.floor (dt - globalTime[target]); delete globalTime[target]; } delete dt; };
Example:
| timerStart | abc | |
| waitForElementPresent | some element | |
| timerStop | abc |
Note:
timerStop function will display the time passed between startTimer and stopTimer in the console log
