views:

784

answers:

4

Hi All,

Can anyone tell me what is the exact flow of taking out xpath in Selenium-IDE. After trying alot by putting alerts i m not getting how to take out the exact xpath. Selenium displays the xpath according to xpath:position and some others ways also but i want to add the xpath traversing from html i.e the topmost position.How can i do that???

A: 

I use XPather to find out the xpath. Then I use the resulting path in the Selenium IDE to cross verify. You could also use other tools like XPath Checker or Firebug to do the same.

+2  A: 

I've come to prefer CSS selectors over Xpath. The IDE won't create them for you, but with a little practice they're very easy to write. As a bonus, they make your tests much easier to maintain.

For example, let's say you have a button with the text "save". The locator would be:

css=button:contains('save')

Check out http://www.w3.org/TR/css3-selectors/ for more detail.

Mark Erdmann
You can get the IDE to create them, see http://reallysimplethings.wordpress.com/2010/10/04/creating-css-locator-builders-for-selenium-ide/
Sam Hasler
A: 

Write 1 line of code in javascript:

LocatorBuilders.order = ['id', 'link', 'name', 'dom:name', 'xpath:link', 'xpath:img','xpath:attributes', 'xpath:href', 'dom:index', 'xpath:position'];

change it the way you want (not all of them has to be there)

see:

chrome://selenium-ide/content/locatorBuilders.js

save as your_file.js

add your_file.js as "Selenium Core extensions" in the IDE options

Ula Karzelek
A: 

Firefinder for Firebug helps matching both CSS and XPath locators

In general, with Firebug installed, you can Inspect Elements for their HTML and DOM structures to determine what best locator you can build.

Nirmal Patel