Test Selenium XPath Expressions Directly in Firefox

January 17th, 2010 § no comments yet

XPather is a small Firefox extension, which I find indispensable (together with Firebug) when writing Selenium tests.

It adds a 'Show in Xpather...' item to the context menu for all the UI elements on the web page. When selected this option opens a small 'XPather Browser' window showing a very, very long XPath expression which selects the element you chose.

Like /html/body/table[2]/tbody/tr[2]/td[2]/div[@id='login']/form[@id='gaia_loginform']/div[@id='gaia_loginbox']/table/tbody/tr/td/div/table[@id='gaia_table']/tbody/tr[8]/td[2]/input, which is the expression you get when you select the 'Sign in' button on the login page of Gmail. Of course you can write your own expressions and test to see what is selected on  the page.  So you can opt to use for example //input[@name='signIn'], which is much shorter and better way to locate the same button. I use XPather mostly to interactively test complex expressions whenever I am trying to locate some hard-to-find object on the web page.

Tagged: , , ,

§ Leave a Reply

What's this?

You are currently reading Test Selenium XPath Expressions Directly in Firefox at Test Automation Blog.

meta