Page 1 of 1

if RepoItemInfo.Exists problem

Posted: Thu Jun 09, 2016 3:30 pm
by agroenen
I'm new at Ranorex, and can't code...

By merging two record-items to user code, I try to get Ranorex click on a button ("Knop") if a RepItemInfo ("Melding") exists. It works fine if the RepoItemInfo-item exists.

But... does it NOT exist, Ranorex is still trying to find the button to click on, and the test fails.

This is the code:


public void Meldingen_Afhandeling(Ranorex.Core.Repository.RepoItemInfo Melding, Ranorex.Adapter Knop)
{
if(Melding.Exists(new Duration(100)))
{
Knop.Click();
}
}

What am I doing wrong...?

Re: if RepoItemInfo.Exists problem

Posted: Fri Jun 10, 2016 12:38 pm
by odklizec
Hi,

I think the problem lies in Ranorex.Adapter Knop declaration. If Ranorex reaches your converted method, it tries to find the passed Adapter and eventually throws an exception, if not found. To avoid this behavior, you must use RepoItemInfo instead of Adapter (like you did for Melding).

So the method declaration should look like this...

Code: Select all

public void Meldingen_Afhandeling(Ranorex.Core.Repository.RepoItemInfo Melding, Ranorex.Core.Repository.RepoItemInfo Knop)
And then you need to create an adapter from RepoItmeInfo, like this:

Code: Select all

public void Meldingen_Afhandeling(Ranorex.Core.Repository.RepoItemInfo Melding, Ranorex.Core.Repository.RepoItemInfo Knop)
{
if(Melding.Exists(new Duration(100)))
{
Knop.CreateAdapter<Unknown>(true).Click();
}
}
It may be better to replace "Unknown" with proper adapter type (e.g. Ranorex.Button, etc.). Just check the available adapter types for Knop element (in Repository element properties). Hope this helps? ;)

Re: if RepoItemInfo.Exists problem

Posted: Mon Jun 13, 2016 3:27 pm
by agroenen
That's it!
Thank you very much!