Automated Test Learning (ii) Selenium IDE feature extensions

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.