cannot identify object in user code

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Nono
Posts: 20
Joined: Wed Oct 02, 2013 11:19 am

cannot identify object in user code

Post by Nono » Mon May 22, 2017 12:37 pm

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

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

Re: cannot identify object in user code

Post by odklizec » Mon May 22, 2017 1:09 pm

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/
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

Nono
Posts: 20
Joined: Wed Oct 02, 2013 11:19 am

Re: cannot identify object in user code

Post by Nono » Mon May 22, 2017 2:41 pm

that solved my issue. I didn't know this could have such an affect. thank you!

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

Re: cannot identify object in user code

Post by odklizec » Mon May 22, 2017 2:46 pm

You are welcome. I'm glad it helped ;)
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