Time for action - finding elements by CSS

So finding Elements by XPath can be an extremely costly exercise. A way around this is to use CSS selectors to find the objects that you need. Selenium is compatible with CSS 1.0, CSS 2.0, and CSS 3.0 selectors. There are a number of items that are supported such as namespace in CSS 3.0 and some pseudo classes and pseudo elements.

The syntax of your locator will look like css=cssSelector. Let's create our first selector to find an element on our page.

  1. Open the Selenium IDE.
  2. Open Firebug and click on the Firefinder tab.
  3. We are going to look at one of the buttons in the div with the ID divontheleft. The CSS Selector for the buttons would be div.leftdiv input. Place that into Firefinder and click on the Filter ...

Get Selenium 1.0 Testing Tools Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.