There are slight differences between Selenium RC and IDE JavaScript functions. Below example will help you in converting the function from one format to another.
Timer extension for IDE from Wiki Link.
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])); delete globalTime[target]; } delete dt; };
The same above functions converted into RC format
var globalTime = new Object(); Selenium.prototype.getTimerStart = function(target) { var dt1 = new Date(); if (target == null || target == "") { return ("Target not present so timer was not started"); } else { globalTime[target] = dt1; return null; } delete dt1; }; Selenium.prototype.getTimerStop = function(target) { var dt = new Date(); if (target == null || target == "") { return ("Please specify a target"); } else if (globalTime [target] == null) { alert("called"); return ("Start time was not called for " + target); } else { return ("Time Passed for " + target + ":" + Math.floor (dt - globalTime[target]) + " msec"); delete globalTime[target]; } delete dt; };
How to call this function from Java, read this Link.
---
No comments:
Post a Comment