Page 1 of 1

get element path with simple mode return unambiguous path

Posted: Wed Sep 15, 2010 3:21 am
by hobli
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>

Re: get element path with simple mode return unambiguous path

Posted: Wed Sep 15, 2010 10:36 am
by Support Team
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

Re: get element path with simple mode return unambiguous path

Posted: Thu Sep 16, 2010 3:13 pm
by hobli
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?

Re: get element path with simple mode return unambiguous path

Posted: Thu Sep 16, 2010 4:05 pm
by Support Team
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

Re: get element path with simple mode return unambiguous path

Posted: Fri Sep 17, 2010 6:45 am
by hobli
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.