Regularize XPath

Best practices, code snippets for common functionality, examples, and guidelines.
SurajJaldu
Posts: 29
Joined: Sat Feb 25, 2012 12:10 am

Regularize XPath

Post by SurajJaldu » Mon Mar 26, 2012 11:59 pm

Hi,

When I add an object to repository I can the XPath as below.

Code: Select all

body/form/div[@id='content']/div[@id='LoginPanel']/span/div[1]/input[@id='Login1_nameTextBox']
I could edit the XPath using Path Editor by removing few parent elements in the hierarchy. Now, I can see the XPath as below.

Code: Select all

*/*/*/*/*/*/input[@id='Login1_nameTextBox']
My question, is there a way to make the path more simple. Probably like '*/input[@id='Login1_nameTextBox']'. Just trying to eliminate the dependency on the hierarchy.

Thanks,
Suraj

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Regularize XPath

Post by Support Team » Tue Mar 27, 2012 1:31 pm

Hi,
SurajJaldu wrote:My question, is there a way to make the path more simple. Probably like '*/input[@id='Login1_nameTextBox']'. Just trying to eliminate the dependency on the hierarchy.
Please take a look to following blog for more information about the RxPath
http://www.ranorex.com/blog/ranorexpath-tips-and-tricks

Regards,
Peter
Ranorex Team

SurajJaldu
Posts: 29
Joined: Sat Feb 25, 2012 12:10 am

Re: Regularize XPath

Post by SurajJaldu » Wed Mar 28, 2012 12:27 am

That was easy and helpful. Thanks Peter :)