Steps
- write the extension code into a new .js file. You can place it anywhere on your drive.
- Open Options - Options... in the menu bar.
- Choose the saved file in "Selenium Core Extensions" field and click OK.
- Restart Selenium IDE by closing the window and opening it again.
Sample Example of User-Extensions.js
Selenium.prototype.doTypeTodaysDate = function(locator){
var dates = new Date();
var day = dates.getDate();
if (day < 10){
day = '0' + day;
}
month = dates.getMonth() + 1;
if (month < 10){
month = '0' + month;
}
var year = dates.getFullYear();
var prettyDay = day + '/' + month + '/' + year;
this.doType(locator, prettyDay);
}
Above code will enter current date in dd/mm/yyyy format in specified Locator(Passeed as argument)
Note: - After adding above User-Extensions.js with selenium IDE , you can see additional command “TypeTodaysDate” in selenium ide command list.
steps to call this function from ide
1. write command "TypeTodaysDate" in selenium IDE
2. Enter Locator in Target ( Locator of webedit , where you want to enter current date)
3. Run selenium IDE
thank you :)
ReplyDeletewhen I attached and, restarted IDE , after that IDE does not show "TypeTodaysDate" command on typing in command text box, and executing this gives error as "[error] Unknown command: 'TypeTodaysDate'"
DeleteWhat could be the reson?
Hi Mahesh,
DeleteCan you try by providing .js file path in 'Selenium core Extension' Field in place of 'Selenium IDE Extensions' field of Selenium IDE option window.
thanks for core it is working fine
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete