Validate.NotExists vs 'Failed to find item'

Class library usage, coding and language questions.
PR91
Posts: 6
Joined: Fri Aug 10, 2018 8:33 am

Validate.NotExists vs 'Failed to find item'

Post by PR91 » Tue Jan 29, 2019 1:32 pm

I have to check the existence of an element on WebPage - element should not be visible.

If i write following code:
(...)
Validate.NotExists(repo.Folder.ElementName);
(...)
or
var Element1= repo.(...);
Validate.NotExists(Element1);


Result is Error: Failed to find item '(...)'.
No element found for path '(...)'

Test should prove that element does not exist, but if the element does not exist test will fail.
How to handle this situation in code ?

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

Re: Validate.NotExists vs 'Failed to find item'

Post by odklizec » Tue Jan 29, 2019 1:45 pm

Hi,

Make sure you are using RepoItemInfo repo element, instead of Adapter! RepoItemInfo does not throw an exception if does not exists. So the code should look like this:

Code: Select all

Validate.NotExists(repo.Folder.ElementNameInfo);
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

PR91
Posts: 6
Joined: Fri Aug 10, 2018 8:33 am

Re: Validate.NotExists vs 'Failed to find item'

Post by PR91 » Tue Jan 29, 2019 2:15 pm

This is solution to the problem.
Thank you :)