if RepoItemInfo.Exists problem

Class library usage, coding and language questions.
agroenen
Posts: 17
Joined: Thu Jun 09, 2016 3:18 pm

if RepoItemInfo.Exists problem

Post by agroenen » Thu Jun 09, 2016 3:30 pm

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...?

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

Re: if RepoItemInfo.Exists problem

Post by odklizec » Fri Jun 10, 2016 12:38 pm

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? ;)
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

agroenen
Posts: 17
Joined: Thu Jun 09, 2016 3:18 pm

Re: if RepoItemInfo.Exists problem

Post by agroenen » Mon Jun 13, 2016 3:27 pm

That's it!
Thank you very much!