Failed to identify item on the second iteration

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Failed to identify item on the second iteration

Post by c676228 » Wed Jun 03, 2015 5:29 pm

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

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

Re: Failed to identify item on the second iteration

Post by Support Team » Fri Jun 05, 2015 2:49 pm

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
.
Image

c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Re: Failed to identify item on the second iteration

Post by c676228 » Sat Jun 06, 2015 11:52 pm

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

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Failed to identify item on the second iteration

Post by krstcs » Mon Jun 08, 2015 2:02 pm

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.
Shortcuts usually aren't...