Is there an addon which you can test css selectors in firefox?

Yes you can go for FireBug, a versatile Firefox web development add-on.

Firebug
(source: getfirebug.com)

To test a CSS selector, go to the "Console" tab and enter a command in the bottom form (more info on how to find the command line).

Firebug command line

Inside the command line use the $$("your CSS selector") syntax to test CSS selectors, explained in more detail here. For example use this command to select everything:

$$("body")

Edit 2019-12-04:

The firefinder addon no longer exists, but you can use the developer console (press F12), and the $$ function to get elements matching a selector, eg. to select all divs: $$('div')

Old answer:

FireFinder does exactly what you are looking for. You can evaluate either CSS, or XPath expressions, it will list the matching elements, and also draw a red border around them.

FireFinder