Page 1 of 1

Failed to identify item on the second iteration

Posted: Wed Jun 03, 2015 5:29 pm
by c676228
Hi,

I have the following xpath:
.//div[#'_container']/div/div/div/div/div[3]/ul/li[@id='btn-action-add']/a[@id='GRPMGMT_ADD_LINK']/span[1]

I works fine usually. Today I noticed that on the second iteration of my data driven test, the mouse somehow move to a bit above target the area, so no ul clickable, the dialog is not opened. So I stopped the Ranorex immediately. And then I click highlight in the repo for this item. it did identify the area above the target item. It looks like .//div[#'_container']/div/div/div/div/div[1]

In the screen shot area, it does catch a square area(which doesn't have visible UI element) above the target item. After refresh and re-highlight a couple of more times, the target area is identified.

I am not sure what causes that. The use cache for the parent folder is set to false. I modify the xpath to the following:
.//div[#'_container']/div[@class='contents']/div[@class='contents-body']/div[@class='inner']/div[@class='primary']/div[3]/ul/li[@id='btn-action-add']/a[@id='GRPMGMT_ADD_LINK']/span[1]
Not sure if it helps.

Any comments?

Thanks,
Betty

Re: Failed to identify item on the second iteration

Posted: Fri Jun 05, 2015 2:49 pm
by Support Team
Hi Betty,

In general the index attribute (for example: div[3]) should only be used if there is no other attribute available in order to identify the element uniquely.
It seems that there are some unique ids available in your application (for example: div[#'_container']). I am wondering why you used the @id attribute in your RanoreXPath instead of the #.

Is it possible to post a Ranorex Snapshot file from your application?
This would help analyzing the issue.

Regards,
Bernhard

Re: Failed to identify item on the second iteration

Posted: Sat Jun 06, 2015 11:52 pm
by c676228
Hi Bernhard,
It seems that the auto-generated xpath usually use # instead of @id. I usually don't change it. But sometimes if there is an issue occasionally, I usually have to add like status = 'complete' or visible = 'True'. then I have to use @id. # basically won't allow you add any other attribute in the path for the UI element.

After our company sign a non-disclosure agreement. I can provide the snapshot.

Thanks,
Betty

Re: Failed to identify item on the second iteration

Posted: Mon Jun 08, 2015 2:02 pm
by krstcs
Betty,

You can add another pair of brackets after the first set, like this:

/div[#'myDiv'][@visible='true']

Basically, Ranorex will find the unique ID and then check if the found div is visible.