Page 1 of 1

Validate.NotExists vs 'Failed to find item'

Posted: Tue Jan 29, 2019 1:32 pm
by PR91
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 ?

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

Posted: Tue Jan 29, 2019 1:45 pm
by odklizec
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);

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

Posted: Tue Jan 29, 2019 2:15 pm
by PR91
This is solution to the problem.
Thank you :)