change searchtime

Best practices, code snippets for common functionality, examples, and guidelines.
IvanT
Posts: 24
Joined: Wed Feb 06, 2019 8:00 pm

change searchtime

Post by IvanT » Thu Sep 12, 2019 3:54 pm

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.

User avatar
qwertzu
Posts: 273
Joined: Wed Jan 25, 2017 11:08 am

Re: change searchtime

Post by qwertzu » Fri Sep 13, 2019 7:46 am

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

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

Re: change searchtime

Post by odklizec » Fri Sep 13, 2019 7:53 am

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

IvanT
Posts: 24
Joined: Wed Feb 06, 2019 8:00 pm

Re: change searchtime

Post by IvanT » Fri Sep 13, 2019 10:36 am

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
}

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

Re: change searchtime

Post by odklizec » Fri Sep 13, 2019 11:16 am

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();
    }
}
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