Page 1 of 1

cannot identify object in user code

Posted: Mon May 22, 2017 12:37 pm
by Nono
Hi,
I am trying to perform a certain validation on a specific object (please see snapshot included in this Dropbox link below).
The object is valid and is recognized when trying to highlight it, but when the user code runs- it cannot be identified. why is that?
this is the function in question:

if(repo.Observer80.IsNotLive.Class.Equals("displayLive"))
{
Report.Info("Success! Live is now off after altering its state in preferences!");
}
else
Report.Error("result","live was not disabled as expected");



and this the error I get:
Failed to find item 'Ranorex8_0Repository.Observer80.IsNotLive'.
No element found for path '/dom[@domain='192.168.10.52']//div[#'Monitor']/div/div[3]/div[2]/div/div[2]/div[1]/div/div/div/div/div[3]/div/div[2]/div[@title='On Air']' within 1m.

any advice? :(

dropbox link:
https://www.dropbox.com/s/tb0s53ruf8bch ... rxsnp?dl=0

Re: cannot identify object in user code

Posted: Mon May 22, 2017 1:09 pm
by odklizec
Hi,

At first sight, there seems to be missing Ranorex plugin in IE. This might cause a significant slowdown of element identification, which may lead to error you are getting (due to expired search timeout). So make sure there is installed and enabled Ranorex plugin in IE.

At second, I would suggest to simplify the xpath (too many nested DIVs) and eliminate the div indexes where possible. I just tried the snapshot and it seems the element in question can be easily found also by this xpath:
/dom[@domain='192.168.10.52']//div[#'Monitor']//div[@title='On Air']
Element indexes are very fragile and should be used only as a last resort, if there is really no other way to uniquely identify the element, which is not your case. In my opinion, it would be better to instruct Ranorex to use "Class" attribute as an additional identification element in your xpaths. This can be done by modifying the xpath weight.

By default, Ranorex eliminates "class" attribute from the xpaths. Usually, they are pretty useless and only clutters the xpaths ;) But in your case, they appear to me much more useful. This is the same xpath like yours, except it now uses Class attribute...
/dom[@domain='192.168.10.52']//div[#'Monitor']//div[@class='application-page-body left-open right-close']/div[@class='application-page-body-middle ']//div[@class='megaWrapper columnMiddle']/div[@class='clipWrapper']//div[@class='playerWrapper_emboss absoluteFill']//div[@class='player-head-foot footer']/div[@class='playerControlGroup rightGroup']/div[@title='On Air']
A detailed explanation how to add "class" attribute to xpath weight can be found in this blog post:
https://www.ranorex.com/blog/automated- ... namic-ids/

Re: cannot identify object in user code

Posted: Mon May 22, 2017 2:41 pm
by Nono
that solved my issue. I didn't know this could have such an affect. thank you!

Re: cannot identify object in user code

Posted: Mon May 22, 2017 2:46 pm
by odklizec
You are welcome. I'm glad it helped ;)