Page 1 of 1

change searchtime

Posted: Thu Sep 12, 2019 3:54 pm
by IvanT
Hi. i need help. how to change search time of elements from user code if i search element like this.
example: Host.Local.FindSingle<ListItem>("/form[@name='OpenProj']/?/?/listitem[@name='"+projectsName+"']").Select();
repository doesn't have this element.
i am testing desktop app.

Re: change searchtime

Posted: Fri Sep 13, 2019 7:46 am
by qwertzu
hi,

could you post a Ranorex Snapshot of the element you are talking about?

In general, elements will most likely be found faster, the more detailed the path is defined.

regards, qwertzu

Re: change searchtime

Posted: Fri Sep 13, 2019 7:53 am
by odklizec
Hi,

FindSingle has a parameter "Duration". Just set it according your needs. I'm curious, why you are not using repository instead? I think it makes things a lot easier ;)

Re: change searchtime

Posted: Fri Sep 13, 2019 10:36 am
by IvanT
I wanna make multipurpose methods open(string value) and i give this values to method. i thing when i write code it's easier for example:
Open("one or two"){
do something
}

Re: change searchtime

Posted: Fri Sep 13, 2019 11:16 am
by odklizec
Hi,

I'm not quite sure I understand what you mean, but you can easily pass repo element along with variable to method of your choice. So let's say you have a repo element with this xpath:

Code: Select all

/form[@name='OpenProj']/?/?/listitem[@name=$projectsName]
Now you can pass the repo element to method of your choice like this:

Code: Select all

public static void DoSomethingWithRepoElements(RepoItemInfo repoElement, string projectsName)
{
   if (repoElement.Exists()) // you can eventually apply custom timeout in Exists() method
    {
        // do whatever you want...
        repoElement.CreateAdapter<Ranorex.Unknown>(false).Click();
    }
}