Object Identification with only visible objects in full path

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
akashb
Posts: 4
Joined: Fri Apr 12, 2013 9:12 am

Object Identification with only visible objects in full path

Post by akashb » Fri Apr 12, 2013 9:50 am

Hello,

I am evaluating Ranorex for our Flex based application.

I am facing an issue with creating xpaths which is kind of showstopper for me to move forward with ranorex.

In our flex application in many cases an object can exists multiple times with exactly same path, but only one of them will have a path where all objects along the hierarchy are visible=true. In all others atleast one object in the path will be visible=false, generally the 'element'

For example in the attached snapshot file , if you search with following xpath:

Code: Select all

/dom[@domain='jsy-memwebvt003:81']//iframe[#'_ctl0_LoadMemotech6']/body/flexobject/container[@id='moduleContainer']//element[@type~'PatentFamilyModule.*']//container[@webpartname='Actions']//text[@text='Create']
Then it will show 2 matches. But 1 of them has an 'element' type object in the hierarchy which is not visible.

Is is somehow possible to create an xpath which can have a condition that only visible objects are searched ?

On googling I got something like

Code: Select all

//input[@name='q' and ancestor-or-self::*[@name='f']]
here :
http://stackoverflow.com/questions/2181 ... ntains-ano

But using such values in Ranorex xpath is not working.

Please guide me as to how I can configure an xpath for such requirement.

Thanks
Akash
You do not have the required permissions to view the files attached to this post.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Object Identification with only visible objects in full path

Post by Ciege » Fri Apr 12, 2013 4:24 pm

You can simply add the following to your xPath "and @visible='True'"

For example, using your xPath above with the new addition:

Code: Select all

/dom[@domain='jsy-memwebvt003:81']//iframe[#'_ctl0_LoadMemotech6']/body/flexobject/container[@id='moduleContainer']//element[@type~'PatentFamilyModule.*']//container[@webpartname='Actions']//text[@text='Create' and @visible='True']
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Object Identification with only visible objects in full path

Post by odklizec » Sat Apr 13, 2013 8:28 am

I'm afraid, adding "@visible='True'" to the last element will not solve his problem. It will still return him two "text='Create'" elements, because both elements are visible='True'. The problem is that one of the ancestors of text='Create' could be visible='False' (as is shown in his attached snapshot). I think he hoped to use something like this...

Code: Select all

//text[@text='Create' and ancestor-or-self::*[@visible='True']]
But this unfortunately does not work.

The closest solution to his problem is something like this...

Code: Select all

/dom[@domain='jsy-memwebvt003:81']//iframe[#'_ctl0_LoadMemotech6']/body/flexobject/container[@id='moduleContainer']//element[@type~'PatentFamilyModule.*']/*[@visible='True']//container[@webpartname='Actions']//text[@text='Create']
But this is not a perfect solution, because it requires the knowledge of particular element, which Visibility could be set to 'False'. So I guess Akash looks for a more general solution, using "ancestor-or-self" feature?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

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

Re: Object Identification with only visible objects in full path

Post by Support Team » Mon Apr 15, 2013 4:17 pm

Hello,

In Ranorex it is possible to use ancestor-or-self as well, but I guess this will not help solving your issue because if you do this, you will get all elements where the visible attribute is true.
For example:
//text[@text='Create']/ancestor-or-self::*[@visible='true']
I would suggest to use a path like the following:
/iframe/body/flexobject/container[@id='moduleContainer']/container/element/element[@visible='True']//text[@text='Create']
Regards,
Bernhard

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Object Identification with only visible objects in full path

Post by odklizec » Tue Apr 16, 2013 7:50 am

Hi Bernhard,

I think it would be a good idea to add support for relationship operators within the attribute value comparisons (currently not supported). So the path would look like this...
//text[@text='Create' and ancestor-or-self::*[@visible='True']]
I think this would be generally useful extension of rxpath attribute comparison?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

akashb
Posts: 4
Joined: Fri Apr 12, 2013 9:12 am

Re: Object Identification with only visible objects in full path

Post by akashb » Wed Apr 17, 2013 6:37 am

Appologies for late reply.

As suggested by odklizec the only good solution would be a support for relationship operators within the attribute value comparisons.

Other than that
/iframe/body/flexobject/container[@id='moduleContainer']/container/element/element[@visible='True']//text[@text='Create']
will also work for current case, but not always as I may not know which object in the hierarchy will be not visible.

I hope support guys would raise feature request for :
1. Enhancement in Ranorex XPath to support axis in attribute value comparison OR
2. Have some kind of configuration setting, so that while searching for object only visible objects are considered throughout the hierarchy.

So as of now I intent to make a custom function to check that all the parents upto some level have visible = true. I hope this will solve my problem, but I am not sure what kind of performance hit it will have.

Thank you everybody for your answers.

akashb
Posts: 4
Joined: Fri Apr 12, 2013 9:12 am

Re: Object Identification with only visible objects in full path

Post by akashb » Wed Apr 17, 2013 7:33 am

Hi

This is what I have come up with to find the first object from the list which is visible upto some parent (flexobject). Not put any error checking right now.

Please let me know if you have any suggestions on improvement or anything else.

Thanks !!!!!!

Code: Select all

void elementSearch()
{
	string qs = "/dom[@domain='jsy-memwebvt003:81']//iframe[#'_ctl0_LoadMemotech6']/body/flexobject//container[@classname='QuickSearchWebpart']";
	FlexObject f = "/dom[@domain='jsy-memwebvt003:81']//iframe[#'_ctl0_LoadMemotech6']/body/flexobject";
	IList<Element> list = f.Element.Find(qs);
	Element e = list[0];
	bool found = false;
	
	Report.Info("List Count",list.Count.ToString());
	
	for (int i=0;i<list.Count;i++)
	{
		Report.Info("Check Visible",i + " : " + list[i].GetPath(PathBuildMode.Reduce));
		if(objectVisible(list[i]))
		{
			e = list[i];
			found = true;
			break;
		}
	}
}

bool objectVisible(Element check)
{
	Element parent = check.Parent;
	string type = parent.Capabilities[0].DisplayName.ToString();
	bool visible = parent.Visible;
	int count = 1;
	Report.Info("Checking Parent","Count : " + count.ToString() + " Type : " + type + " xpath : " + parent.GetPath(PathBuildMode.Reduce));
	
	while (!type.Equals("FlexObject") && visible == true)
	{        		
		parent = parent.Parent;
		type = parent.Capabilities[0].DisplayName.ToString();
		Report.Info("Checking Parent","Count : " + count.ToString() + " Type : " + type + " xpath : " + parent.GetPath(PathBuildMode.Reduce));
		if (parent.Visible == false)
			visible = false;
		count ++;
	}
	
	Report.Info("Object Visible","Exit : " + visible + " Count : " + count);
	return visible;
}

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

Re: Object Identification with only visible objects in full path

Post by Support Team » Thu Apr 18, 2013 3:58 pm

Hello,

Using "ancestor-or-self" is already possible for the adapters as you can see in my previous post.
//text[@text='Create' and ancestor-or-self::*[@visible='True']]
This is not possible because you try to use an adapter as attribute.
Regarding a setting, we will discuss this feature internally.
You can also use OR logic in Ranorex. Please take a look at the following example.
/form[@title='Untitled - Paint' or @title='Calculator']
Unfortunately it is not possible to mix adapters and attributes as you are trying to do.

Regards,
Bernhard

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Object Identification with only visible objects in full path

Post by odklizec » Fri Apr 19, 2013 7:34 am

Hi Bernhard,

Yes, it's currently not possible to evaluate adapters with attributes. The question is, if it could be implemented in a future?

The thing is, that mixing adapters and attributes seems to be perfectly OK in basic xpath implementation? Please see the answer in this post:
http://stackoverflow.com/questions/2181 ... ntains-ano

Basically, the answer suggests to use the syntax, which is currently not supported by Ranorex:
//text[@text='Create' and ancestor-or-self::*[@visible='True']]


I tested the above xpath in xpath visualizer and it appears to be syntactically correct (in respect of basic xpath definition). So it seems it's just Ranorex that does not support evaluation of xpath with mixed adapters and attributes?

I personally don't have a specific need for solving this problem. But I see a great potential in such path evaluation approach. I think Akash's problem is a perfect example. If user knows that there could be some ancestor elements in the path that could be invisible and he don't know their exact location (or the location of invisible ancestor elements could change within the path), it would be extremely useful to use the evaluation of attribute and adapter as we already discussed. What do you think?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

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

Re: Object Identification with only visible objects in full path

Post by Support Team » Fri Apr 19, 2013 10:16 am

Hello,

I will treat this as feature request and will add this into our bug tracking system.
We will discuss this feature internally and our developers will check this in more detail.
Thank you for the input.

Regards,
Bernhard