Add Jquery (Sizzle) selectors to Selenium


First, download Sizzle, which is a selector engine for jQuery and unpack sizzle.js to a convenient location.

Second, create empty user-extensions.js file. Name can be whatever you want by the way.

Add this to user-extensions.js

1 PageBot.prototype.locateElementBySizzle = function(locator, inDocument) {
2   var results = [];
3   window.Sizzle(locator, inDocument, results);
4   return results.length > 0 ? results[0] : null;
5 }

Third, go to Selenium IDE, Options -> Options… and add sizzle.js and user-extensions.js to “Selenium Core extensions”.

Restart Selenium IDE (just close all instances of it and open it again), and now you can use sizzle=(locator) everywhere, where “locator” is needed

One example of usage is:

Command: verifyElementPresent
Target: sizzle=body
Value: true

This test should succeed on every normal HTML page.