Showing posts with label Assertion methods in Selenium. Show all posts
Showing posts with label Assertion methods in Selenium. 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);
};