get element path with simple mode return unambiguous path

Ask general questions here.
hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

get element path with simple mode return unambiguous path

Post by hobli » Wed Sep 15, 2010 3:21 am

Hi, Ranorex staff,

I tried use the following code to compare the Rxpath returned for 2 link elements in a html file:

Code: Select all

Dim a As ATag = "/dom[@page='simpleMode.html']/body/a[1]"
	a.EnsureVisible()
Dim pathReduce As RxPath = a.GetPath(PathBuildMode.Reduce)
Dim pathSimple as RxPath = a.GetPath(pathbuildmode.Simple)
I found that the path returned with 'simple' mode can not uniquely identify the link element.

reduced mode path: "/dom[@page='simpleMode.html']/body/a[1]"
simple mode path: "/dom[@page='simpleMode.html' and @path='C:/Documents%20and%20Settings/rndgrp/Desktop/simpleMode.html' and @browsername='Mozilla']/body[pos()='1']/a[@innertext='aa' and @href='a.html']



Pls use the following html code to reproduce:

Code: Select all

<html>
<head>
</head>
<body>
<a href="a.html">aa</a>
<a href="a.html">aa</a>
</body>
</html>

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: get element path with simple mode return unambiguous path

Post by Support Team » Wed Sep 15, 2010 10:36 am

Hi,

Simple means:
No optimization is performed. Path predicates contain all valid, appropriate and existing attribute values or indexes if no attributes can be used.

Reduce means:
Reduces the number of path predicates such that the path remains non-ambiguous. This usually shortens the path and makes it more robust by eliminating unnecessary attributes.

Regards,
Peter
Ranorex Team
.
Image

hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

Re: get element path with simple mode return unambiguous path

Post by hobli » Thu Sep 16, 2010 3:13 pm

Hi,

So does it mean that if I use "simple" mode, ranorex may not return a Rxpath which can un-ambiguously identify an element? I thought the only difference between "simple" mode and "reduced" mode is simple does not do optimization, but it should at least ensure the uniqueness of the element with the Rxpah returned.

am I correct?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: get element path with simple mode return unambiguous path

Post by Support Team » Thu Sep 16, 2010 4:05 pm

Hi,

Ranorex tries to suggest you the best RxPath but in some cases, as in your example, it is not possible, because there are only a few attributes to identify the element. If you use the reduce mode an optimization is performed and therefore the element is unique.

Regards,
Peter
Ranorex Team
.
Image

hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

Re: get element path with simple mode return unambiguous path

Post by hobli » Fri Sep 17, 2010 6:45 am

So the conclusion is:

With simple mode, Ranorex may not always return rxpath which can uniquely identify an element, while by using Reduced mode, the uniqueness is ensured.

thanks for explanation.