Generate robust Xpaths

192 views
Skip to first unread message

Martin Spamer

unread,
Apr 24, 2014, 6:49:14 AM4/24/14
to fire...@googlegroups.com

The xpaths generate by FirePath are brittle because they are fully qualified rather than focused.

Take the following examples; generated by FirePath for a form I have on a page.

html/body/div/form/div[1]/select, html/body/div/form/div[2]/select

If the page changes all the xpaths are broken.

I want to use FirePath to provide the xpath for element selectors @FindBy(...) with Selenium WebDriver.  It would be really useful for FirePath to be able to generate a optimised / focused  xpath based on id or name elements.  which needs xpath that are robust.

e.g.

//form[@name='Market']
//select[@id='market-group-name']
//select[@name='market-group-name']

Mason Foley

unread,
Apr 24, 2014, 4:21:22 PM4/24/14
to fire...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "FirePath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firepath+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pierre Tholence

unread,
Apr 24, 2014, 9:19:53 PM4/24/14
to fire...@googlegroups.com
Hi Martin,

Note that FirePath support  the creation of more optimized/focused XPath using the id of the element or the id of its closest parent with an id.
To enable this feature, go in the FirePath menu (See attached screenshot) and unselect "Generate Absolute XPath".
Let me know if this is what you are looking for.

Regards,
Pierre



On Thu, Apr 24, 2014 at 6:49 AM, Martin Spamer <martin...@gmail.com> wrote:

--
FirePath Menu.png

Martin Spamer

unread,
Apr 28, 2014, 6:00:00 AM4/28/14
to fire...@googlegroups.com

Hi Pierre, thank you for responding.

That option was unchecked when viewed and I've tried having it both checked and unchecked and it seems to produce the same result.

html/body/div/form/table/tbody/tr[2]/td[1]/input - Generate Absolute Xpath  is unchecked/ not ticked

html/body/div/form/table/tbody/tr[2]/td[1]/input - Generate Absolute Xpath  is checked/ is ticked

Thanks

Martin
Reply all
Reply to author
Forward
0 new messages