Showing posts with label selenium IDE. Show all posts
Showing posts with label selenium IDE. Show all posts

Monday, August 20, 2012

Adding assertion Methods to Selenium Library



Add following code to user extensions js file

Method is getCurrentTime and it returns the currenTime\

// Return the currentTime in the format HH:MM:SS

Selenium.prototype.assertCurrentTime = function(locator,value) {

   var expValue = value; //Getting excepted Value

   // Get Actual Value
   var d = new Date();
        var curr_hour = d.getHours();
        var curr_min = d.getMinutes();
        var curr_sec = d.getSeconds();

        var actValue = curr_hour+':' + curr_min + ':'+ curr_sec;

  //Doing assertion for excepted and Matches Value
   Assert.matches(expValue, actValue);
};

Adding new method to Selenium User Extensions

Below steps are required for adding the method to user extension js file. User can use the following method "getCurrentTime" as selenium function for returning the currentTime.


Add following code to user extensions js file

Method is getCurrentTime and it returns the currenTime\

// Return the currentTime in the format HH:MM:SS

Selenium.prototype.getCurrentTime = function(currentTime){

        var d = new Date();
        var curr_hour = d.getHours();
        var curr_min = d.getMinutes();
        var curr_sec = d.getSeconds();

        currentTime = curr_hour+':' + curr_min + ':'+ curr_sec;
        return currentTime;

};