Page 1 of 1

Passing objects to methods that aren't visible

Posted: Thu Jan 07, 2010 7:40 pm
by jlowder
Hello,

I have a number of list items that are not present on the screen at the time I want to access them. I created a simple method to pass in the object and do a while not visible click on the scroll down arrow button. Once the object is visible access it. Problem is, when passing the object name via the method, Ranorex looks for the object right then and fails. I can't even get to the point of saying "I know it's not there yet, so do this until it is".

My code is:

FindScrubber(repo.Gen2Interface.ScrubbingTab.ScrubTestList.TrimLeft);

public static void FindScrubber(Text scrubTest)
{

while (scrubTest.Visible == false)
{
repo.Gen2Interface.ScrubbingTab.ScrubTestList.ButtonScrollDown.Click();
}

scrubTest.Click();
}

How do I get around this problem? I have over 40 objects that fit this so I need to create a method that pulls them all into view.

Thanks,

Jason

Re: Passing objects to methods that aren't visible

Posted: Thu Jan 07, 2010 8:31 pm
by Support Team
You are right, to get an adapter instance (e.g. "Text scrubTest"), you must first find it, i.e. the UI element must already be there for Ranorex to create the corresponding object. However, you can use the corresponding RanoreXPath or the RepoItemInfo object instead and check whether the element already exists by evaluating the RepoItemInfo.Exist method:
FindScrubber(repo.Gen2Interface.ScrubbingTab.ScrubTestList.TrimLeftInfo);

public static void FindScrubber(RepoItemInfo scrubTestInfo)
{
    Text scrubTest;
    while (!scrubTestInfo.Exists(out scrubTest) || scrubTest.Visible == false)
    {
        repo.Gen2Interface.ScrubbingTab.ScrubTestList.ButtonScrollDown.Click();
    }

    scrubTest.Click();
}
Regards,
Alex
Ranorex Support Team

Re: Passing objects to methods that aren't visible

Posted: Thu Jan 07, 2010 8:48 pm
by jlowder
Hi Alex,

I had tried passing in the info but didn't have the RepoItemInfo object, descriptor or whatever. (what do you call these things like RepoItemInfo that you are setting the variables to?).

This does, however, fail with the error:

The type or namespace name 'RepoItemInfo' could not be found (are you missing a using directive or an assembly reference?) (CS0246) - C:\QA\RanorexAutomation\Gen2\SourceExtract\SourceExtract\Scrubber.cs:72,35

Do I need to be including something more than Ranorex and Ranorex.Core in my using statements?

Thanks,

Jason

Re: Passing objects to methods that aren't visible

Posted: Thu Jan 07, 2010 9:26 pm
by Support Team
The RepoItemInfo is just a helper class that stores the RanoreXPath (and some additional info) for a repository item. Is has been introduced with Ranorex V2.2. The following using statement should help getting rid of the compiler error:
using Ranorex.Core.Repository;
Regards,
Alex
Ranorex Support Team