How to 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

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

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

8 thoughts on “How to add jQuery (Sizzle) selectors to Selenium

  1. Pingback: Run Selenium IDE tests with jQuery selectors « CSS Greut

  2. Pingback: Get element with jquery and selenium IDE 1.0.8. - Stack Overflow

  3. Pingback: jQuery Buzz - How to add jQuery (Sizzle) selectors to Selenium | German Rumm's blog

  4. Pingback: Get element with jquery and selenium IDE 1.0.8 - Stack Overflow - PinoyTech

  5. Pingback: Run Selenium IDE tests with jQuery selectors | Tom’s view on web development

  6. Pingback: Run Selenium IDE tests with jQuery selectors | Tom's view on web development

  7. Pingback: Selenium for Automation – Testing Axial-Style Part 1 | Corps of Engineers

  8. Pingback: scubaworks | Corps of Engineers

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

captcha service