Through the study of the previous section, I believe we have selnium the basic use of the IDE, in order to make the selenium more powerful, in fact, selenium also provides a good expansion capability.
----//user Extensions
User extensions are the use of JavaScript files to create custom features, add new functionality, typically this extension is a custom command, but the extension is not limited to the command.
Here are some extensions to the columns: http://wiki.openqa.org/display/SEL/Contributed+User-Extensions
1. Below we use the extension of the way to produce a random number of users
In order to use the user extensions, we need to create a file, of course, can also be downloaded from the link above. File name: User-extention.js
Generate random number
Selenium.prototype.doStoreRandom = function (variableName) {
random = Math.floor (Math.random () * 10000000);
Storedvars[variablename] = random;
}
Pop-up box
Selenium.prototype.doDisplayAlert = function (value, varName) {
alert (value);
}
Enter the current date in the control
Selenium.prototype.doTypeTodaysDate = function (Locator) {
var dates = new Date ();
var day = Dates.getdate ();
if (Day < ten) {Day
= ' 0 ' + day;
}
month = Dates.getmonth () + 1;
if (Month <) {
month = ' 0 ' + month;
}
var year = Dates.getfullyear ();
var prettyday = day + '/' + month + '/' + year;
This.dotype (Locator, ' dddddd ');
}
Copy the above code into a notepad and save it as a: User-extention.js file
Import this file in the selenium IDE, as shown in the following figure: