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 Formats tab, and click Add
- A new dialog opens. Enter arbitrary name into "Name of the format" field.
- Open the downloaded .js file with the text editor, 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 disk.
- 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 one .js file and just enter the path for this one file in step 3 above.
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 events occured in a page by putting the following code as Selenium IDE extension.
Recorder.removeEventHandler('clickLocator');
Recorder.addEventHandler('clickLocator', 'click', function(event) {
if (event.button == 0) {
this.clickLocator = this.findLocator(event.target);
}
}, { capture: true });
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.
Download img-title-command.js
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,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 | clickAndWait | clickAndWait |
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.
Selenium IDE FlowControl
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.
Locators
To use the locators:
- Download or copy the locator code into a new .js file. You can place it anywhere on your disk.
- 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 you add new ones or not). 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
why there is no "UI-Element Locator" extension's for Selenium Core?