Passing objects to methods that aren't visible

Ask general questions here.
jlowder
Posts: 55
Joined: Wed Dec 30, 2009 2:56 pm

Passing objects to methods that aren't visible

Post by jlowder » Thu Jan 07, 2010 7:40 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Passing objects to methods that aren't visible

Post by Support Team » Thu Jan 07, 2010 8:31 pm

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

jlowder
Posts: 55
Joined: Wed Dec 30, 2009 2:56 pm

Re: Passing objects to methods that aren't visible

Post by jlowder » Thu Jan 07, 2010 8:48 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Passing objects to methods that aren't visible

Post by Support Team » Thu Jan 07, 2010 9:26 pm

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