Question

I'm using selenium in my test suite, but since it's slow to set up, I'd like to prototype my xpaths on live pages, rather than waiting for tests to run. Is there a good way to do this?

  • Firebug's $x xpath seems to not work very well
  • jQuery doesn't seem to support Xpath selectors natively, though it used to in version 1.2.
  • using the native javascript stuff (document.evaluator(...)) is verbose and doesn't return lists, making it irritating to use.

What's a good solution? Perhaps there's a way to use selenium as a nice REPL directly?

Was it helpful?

Solution

Download the Selenium IDE Firefox plugin. It has what you're looking for and more.

You can enter an xpath, and it'll highlight the resulting elements for you. There's also drop-downs to select the Selenium functions you want to invoke.

It also adds context sensitive entries to your context menu (right click some text, then "AssertEquals" on it for example.)

OTHER TIPS

Use the XPather add-on for Firefox. I always use it to check out my XPaths.

Also consider using TestPlan to write your tests. It has Selenium and HTMLUnit as a backend. Since HTMLUnit doesn't open a browser your tests run a lot quicker. Once everything is working with HTMLUnit you can just run in Selenium mode and have the same test work in the browser.

http://testplan.brainbrain.net/

Firefinder is a nice plugin too, maybe slightly nicer than firebug, maybe not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top