This page is a repository for user-contributed custom formats and extensions. If you have written a useful format code that can be shared, add it to this page.
For writing custom formats and extensions, see Adding Custom Format and Writing extensions.
Formats
To add these formats:
- Download the .js file attached in each page.
- Open Options - Options... in the menu bar. Click the Formats tab, and then click Add.
- A new dialog opens. Enter an arbitrary name into the "Name of the format" field.
- Open the downloaded .js file with the text editor, then copy and paste the code into the text area in the opened dialog.
- Click OK in the dialogs.
- The new format will appear under Options - Formats in the menu bar.
Selenium on Rails
A Wiki-like format that can be used in Selenium on Rails. more...
Java driven Selenium
Can be used to generate or modify JUnit tests for Java driven Selenium. more...
Alternatively TestNG users can try this expiremental TestNG java driven Selenium. more...
Extensions
To use the extensions:
- Download or copy 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 IDE Extensions" field and click OK.
- Restart Selenium IDE by closing the window and opening it again.
If you use several extensions or locators, you may prefer to append the contents of each .js file and just enter the path for this one file in step 3 above.
Record Special Keys
This extension will make Selenium IDE (1.7.2) record keydown and keyup commands for the following keys: ctrl, alt, shift, meta. This will make it easier to record ctrl click sequences and other not so difficult things to code. I just made this because Selenium should record certain key events by default. I mean, what else would we press the buttons for while recording? XD
☭ Hial Atropa!! ☭
Download the extension from the attachments on this page or save this link: RecordSpecialKeys.js
Record mousedown and mouseup
Record mousedown and mouseup events in Selenium 1.7.2 Supports left and right buttons (0 and 2).
☭ Hial Atropa!! ☭
Download the extension from the attachments on this page or save this link: RecordMouseDownUp.js
Generate random text in a variable
Create a variable that has randomly generated characters.
| randomString | options | varName |
Use varName as you would any variable (e.g., $
)
'options' can be nothing, a number, one of the words 'alpha', 'numeric' or 'alphanumeric' or a pipe-delimited string containing either of those.
'8|alpha' and 'alpha|8' both do the same thing.
// Generate random text for a variable // Possible options: // length number indicating how long to make the string (defaults to 8) // // type string indicating what type of string to create alpha, numeric // or alphanumeric (defaults to alphanumeric) // // length|type pipe delimited option list Selenium.prototype.doRandomString = function( options, varName ) { var length = 8; var type = 'alphanumeric'; var o = options.split( '|' ); for ( var i = 0 ; i < 2 ; i ++ ) { if ( o[i] && o[i].match( /^\d+$/ ) ) length = o[i]; if ( o[i] && o[i].match( /^(?:alpha)?(?:numeric)?$/ ) ) type = o[i]; } switch( type ) { case 'alpha' : storedVars[ varName ] = randomAlpha( length ); break; case 'numeric' : storedVars[ varName ] = randomNumeric( length ); break; case 'alphanumeric' : storedVars[ varName ] = randomAlphaNumeric( length ); break; default : storedVars[ varName ] = randomAlphaNumeric( length ); }; }; function randomNumeric ( length ) { return generateRandomString( length, '0123456789'.split( '' ) ); } function randomAlpha ( length ) { var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( '' ); return generateRandomString( length, alpha ); } function randomAlphaNumeric ( length ) { var alphanumeric = '01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( '' ); return generateRandomString( length, alphanumeric ); } function generateRandomString( length, chars ) { var string = ''; for ( var i = 0 ; i < length ; i++ ) string += chars[ Math.floor( Math.random() * chars.length ) ]; return string; }
Recording every clicks on page
By default, Selenium IDE only records click events on certain types of elements (e.g. <a>, <input type="button">, ...).
You can record any click event on a page by putting the following code as a Selenium IDE Extension.
Recorder.removeEventHandler('clickLocator');
Recorder.addEventHandler('clickLocator', 'click', function(event) {
if (event.button == 0) {
this.clickLocator = this.findLocator(event.target);
}
}, { capture: true });
Code above is not working in Selenium IDE 1.7.2 See the attachment RecordAllClicks.js for an updated working version. ☭ Hial Atropa!! ☭
Recording clicked coordinates
This extension records "clickAt" commands instead of "click" commands.
Recorder.removeEventHandler('click');
Recorder.addEventHandler('clickAt', 'click', function(event) {
var x = event.clientX - editor.seleniumAPI.Selenium.prototype.getElementPositionLeft(event.target);
var y = event.clientY - editor.seleniumAPI.Selenium.prototype.getElementPositionTop(event.target);
this.record('clickAt', this.findLocator(event.target), x + ',' + y);
}, { capture: true });
Commands for Image Title
This adds commands like assertText //img@title Our Logo to the right-click menu. It is well commented and can serve as the basis for writing your own command extensions. Changing this to work with the the alt and src attributes will require only minor changes.
Commands for Selected Label of a Drop Down
This adds commands like assertSelectedLabel Complexity Minor to the right-click menu. It is well commented and can serve as the basis for writing your own command extensions.
Download selected-label-command.js
Commands for Available Options in a Drop Down
This adds commands like assertSelectOptions Complexity None, Minor, Major, and Maximum to the right-click menu.
Download select-options-command.js
Commands for Presence of a Table
This adds commands like verifyElementPresent and waitForElementPresent for the entire table to the right-click menu. This is in addition to the standard table.row.col commands. This can be useful to check if the table is there for pages where Ajax draws the table.
Download table-present-command.js
Commands for Number of Rows in a Table
You MUST install the getTableRows Selenium Core Extension to use this.
Adds commands to assert, verify etc. the number of rows in a table if a click is inside of it. It only finds the closest enclosing table.
Download table-rows-command.js
Commands to Test Input Editability
You MUST install the inputIsEditable Selenium Core Extension to use this.
Adds right-click command to assert, verify etc., IF the selected element is an editable input or something else (disabled input, span, div, etc.). e.g. The non-editable format looks like
<span id="HomePhoneNumber>(777) 777-7777</span>
or
<input disabled id="HomePhoneNumber name="HomePhone" value="(777) 777-7777">
And the editable form looks like:
<input id="HomePhoneNumber name="HomePhone" value="(777) 777-7777">
Download input-is-editable-command.jss
UI-Element Locator
UI-Element is an extension for the Selenium IDE and Remote Control that makes it possible to define a mapping between semantically meaningful names of elements on webpages, and the elements themselves. The mapping is stored in a file using JavaScript Object Notation. The file may be shared by the IDE and driven tests running via the Selenium server. It also offers a single point of update should the user interface of the application under test change. UI-Element is available under the GNU General Public License.
Something that used to look like this:
clickAndWait | //a[contains(text(),'Educate Your Stakeholders!')] clickAndWait | //a[contains(text(),'Shane Diffily')] clickAndWait | //a[contains(text(),'Content')]
Can now look like this:
clickAndWait | ui=issuePages::article(index=2) clickAndWait | ui=articlePages::author() clickAndWait | ui=allPages::topics(topic=Content)
Download the extension bundled with Selenium IDE. See my UI-Element blog entry for documentation. Documentation is now also included with the extension itself.
Commands to control execution flow within test cases
A port of the Selenium Core FlowControl extension for Selenium IDE provides if-else and while-loop functionality within the Selenium IDE.
Example:
store | 10 | x gotolabel | target1 | getEval | alert("Skip This"); | label | target1 | store | 14 | y gotoIf | ${y} > ${x} | target2 getEval | alert("Skip This"); | label | target2 | while | storedVars['x'] <= storedVars['y'] | getEval | storedVars['x'] = ${x} + 1; | endWhile | | getEval | alert("Finished"); |
The following commands are available:
goto gotoAndWait gotoIf gotoIfAndWait gotolabel gotolabelAndWait while whileAndWait endWhile endWhileAndWait
Download the file and see this blog entry for detailed instructions and to download the source.
Alternatives
The above item is 3 years old. Newer options, in decreasing order of capability:
- A more recent, and more fully featured, suite of flow control tools is available as a FireFox add-on -- http://addons.mozilla.org/firefox/addon/selenium-ide-sel-blocks . Within OpenQA, you can find its source here -- http://wiki.openqa.org/display/SEL/Selblocks
- This -- https://github.com/martinhbramwell/selenium-ide-flowcontrol -- is the latest version of Selenium IDE FlowControl, packaged as a FireFox plugin. There is all the source code and build scripts for both Linux and Windows. You will also find a simple test suite, which you can use to verify browser compatibility and that your build went ok and to understand usage scenarios.
- The preceding is a bug-fixed fork of this work by Dave Hunt -- https://github.com/davehunt/selenium-ide-flowcontrol
- Furthermore, Dave Hunt's work above is just a FireFox plugin package fork of Darren Deridder's original flow control work, to be found here -- https://github.com/darrenderidder/sideflow
Locators
To use the locators:
- Download or copy the locator 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 IDE Extensions" field and click OK.
- Restart Selenium IDE by closing the window and opening it again.
Ordering Locators
You may find that you need a different order for the locators (whether or not you add new ones). To do this, make a .js file containing this line:
LocatorBuilders.order = ['id', 'link', 'name', 'dom:name', 'xpath:link', 'xpath:img', 'xpath:attributes', 'xpath:href', 'dom:index', 'xpath:position'];
Then follow the instructions above using this file for the locator file.
Locator for Links Wrapping HTML Tags (enclosingLink locator)
This locator REQUIRES release 1.0 (tested with Beta 2). It WILL NOT work with the 0.8.7 or early releases of SIDE.
If you click on a link that contains other HTML tags, the Selenium IDE will (or may depending on what is in the tag and where you click) generate a location for the HTML tag inside of the link. e.g. for this HTML,
<td class="ajaxGridSelectRow"> <a href="..." id="ToggleRowSelection_03764835B722"> <span> </span> </a> </td>
It will generate a location like //td[1]/a/span rather than the desired id ToggleRowSelection_03764835B722. While this will function when running the test, it can make then harder to comprehend.
This locator will search for an enclosing link and create a location directly for the link.
Use name 'enclosinglink' in LocatorBuilders.order for this locator. It must appear before the dom: and xpath: locators.
Follow the instructions above to add this file to "Selenium IDE extensions"
Download enclosingLinkLocator.js
Follow the instructions above BUT add this file to "Selenium Core extensions" (user-extensions.js)
Download enclosingLinkStrategy.js

Comments (3)
Jul 05, 2007
R says:
why there is no "UI-Element Locator" extension's for Selenium Core?why there is no "UI-Element Locator" extension's for Selenium Core?
Jul 06, 2007
kellyding says:
how to use ""UI-Element Locator" extension's in selenium IDE?how to use ""UI-Element Locator" extension's in selenium IDE?
Oct 11, 2010
Sachin Telang says:
Hi, I am using selenium IDE and it is not showing 'geteval' command. plz ...Hi,
I am using selenium IDE and it is not showing 'geteval' command. plz help what to do