Archive for validatie

Run Selenium IDE tests with jQuery selectors

This took me a lot of time to find out, so here is a short and handy overview for everyone that wants to use jQuery selectors instead of Xpath selectors in their Selenium IDE tests. First the steps to achieve this, followed by some comments for the few readers that are still interested.

Add jQuery selectors to Selenium

  1. The selector engine of jQuery is called Sizzle. Download it from sizzlejs.com and store the file sizzle.js in your Selenium project. (I used the current version, 1.0.)
  2. Create a blank JavaScript file, rename it to “user-extensions.js” and save it to your Selenium project.
  3. Add the following code to “user-extensions.js”:
    PageBot.prototype.locateElementBySizzle = function(locator, inDocument) {
    var results = [];
    window.Sizzle(locator, inDocument, results);
    return results.length > 0 ? results[0] : null;
    }
  4. Open Selenium IDE from Firefox.
  5. Go to Options > Options > General.
  6. Click the “Browse …”-button of “Selenium Core extensions (user-extensions.js)”
  7. Multiple select “sizzle.js” and “user-selections.js”. They should be added comma-seperated to the input field (for example: “D:\myProject\user-extensions.js, D:\myProject\sizzle.js“).
  8. Restart Selenium IDE.
  9. Execute the following test:

Command: verifyElementPresent
Target: sizzle=body
Value: true

This test should succeed on every normal HTML page. ;)

Comments

  • Why use Sizzle and not the complete¬† jQuery library? The same setup can also be used for jQuery, but I could not get it working. Some say that recent versions of jQuery (I use 1.4.4) don’t cope with Selenium, at the moment.
  • It’s still possible though to use jQuery functionality in your tests. If jQuery is available on the page you are testing, one could do a test similar to:

Command:assertEval
Target: selenium.browserbot.getUserWindow().jQuery("body").length
Value: 1

 

Helpful resources

 

Advertenties

Geef een reactie

Bulk HTML validation

In addition to the Dutch webrichtlijnentoets you can now do a bulk validation on a complete website with the marvelous Nikita the Spider. Nikita does HTML validation and searches for broken links and more. However, it’s still in alpha and the job has to be started by hand, so be patient! (via EGS)

Tags: , , ,

Comments (2)

Webrichtlijnentoets

Als je benieuwd bent in hoeverre je code voldoet aan de webrichtlijnen van de overheid kun je je site door de Webrichtlijnentoets heenhalen. De punten van de richtlijnen die automatisch te controleren zijn, worden dan getoetst. Raph heeft er ook een handige bookmarklet bij gemaakt.

Tags: , ,

Comments (1)

CSS Validation Service vernieuwd

Op The Elementary Group Standards wordt opgemerkt dat de W3C al een jaar bezig is met een nieuwe CSS Validation Service. Je kunt hem echter al gewoon gebruiken en CSS3 wordt ook ondersteund. Lang leve de eeuwige beta!

Tags: , , ,

Geef een reactie