Page 1 of 1

Caching of elements

Posted: Tue Jun 27, 2017 2:37 pm
by i.vasilyev
Ranorex v7.0.1
Windows 10 Pro
Windows desktop application
VS2015

Hello.
I have a problem. I want to fill in required fields in form. The number of fields is more then 10. Finding of one element takes about 7 seconds(I was talking with support team and all possible things were done for optimize performance of finding elements, so the rxPathes are good), so it is needed more than minutes for filling all fields(I'm researching each element each time). Is it possible to cache the parent of this elements with its childs?

I can't provide the snapshot. but structure is following:

Code: Select all

form
       element1
                   element
                               tabpagelist
                                               textbox1
                                               textbox2
                                               ...
                                               textboxn
       element2
       ...
       elementN
I want to fill in textbox1-N

Re: Caching of elements

Posted: Tue Jun 27, 2017 2:43 pm
by Vaughan.Douglas
I believe Ranorex caches objects by default.

What does your RxPath look like? Are you using rooted folders in the repository?

Re: Caching of elements

Posted: Tue Jun 27, 2017 3:09 pm
by i.vasilyev
It looks as following:
/form/element1/element/tabpagelist/textbox1
Are you using rooted folders in the repository?
I'm not sure that I know what is it

Re: Caching of elements

Posted: Tue Jun 27, 2017 3:22 pm
by Vaughan.Douglas
i.vasilyev wrote:It looks as following:
/form/element1/element/tabpagelist/textbox1
Are you using rooted folders in the repository?
I'm not sure that I know what is it
Here is a video on organizing your object repository. More helpful videos can be found here.

Re: Caching of elements

Posted: Tue Jun 27, 2017 3:28 pm
by i.vasilyev
I'm not using the repository and ranorex studio. I'm using VS+Ranorex.Core library. It means that i'm using FindSingle each time.

Re: Caching of elements

Posted: Tue Jun 27, 2017 5:34 pm
by Vaughan.Douglas
i.vasilyev wrote:I'm not using the repository and ranorex studio. I'm using VS+Ranorex.Core library. It means that i'm using FindSingle each time.
Are you doing a FindSingle on the host each time or have you stuck the application into a variable and doing a findsingle on that?
var myForm = new Ranorex.Form(Host.Local.FindSingle("/form"));
myForm.FindSingle<Ranorex.Unknown>("/element1").PressKeys("blah Blah Blah");
myForm.FindSingle<Ranorex.Unknown>("/element2").PressKeys("blah Blah Blah");
//...
myForm.FindSingle<Ranorex.Unknown>("/elementN").PressKeys("blah Blah Blah");

Re: Caching of elements

Posted: Tue Jun 27, 2017 7:13 pm
by i.vasilyev
Are you doing a FindSingle on the host each time or have you stuck the application into a variable and doing a findsingle on that?
Yes, i'm doing FindSingle on the Host each time
Will try to use your example, but not sure that it will help me because looks like a problem with a form itself(too many elements are under that form)

Re: Caching of elements

Posted: Wed Jun 28, 2017 8:50 am
by i.vasilyev
var myForm = new Ranorex.Form(Host.Local.FindSingle("/form"));
myForm.FindSingle<Ranorex.Unknown>("/element1").PressKeys("blah Blah Blah");
As I expected this solution not helped me. The search time is the same. Can you provide some other way? Is it possible to use multithreading for finding two or more elements at the same time?

Re: Caching of elements

Posted: Wed Jun 28, 2017 9:06 am
by odklizec
Hi,

The problem is, that if the xpath for searched element is not specific enough and according your previous posts, there is a lot of elements under the searched form? So it will always take some time to find the element. Repo folder caching would most probably help, but because you are not using repo, you will most probably have to improve the searched xpath or start search from different element. May I ask you why you are not using Studio? You see, by not using Studio (and especially repository), you are cutting yourself from many Ranorex advantages, which are not available in visual studio.

Re: Caching of elements

Posted: Wed Jun 28, 2017 9:18 am
by i.vasilyev
I had a call with Ranorex Support team and we tried to use Ranorex Studio and repositories, but there are no visible benefits of using studio+repository. I'm talking about searching perfomance. Looks like it is because
of our application's element structure, but not sure.
The problem is, that if the xpath for searched element is not specific enough and according your previous posts, there is a lot of elements under the searched form?
My rxPath is specific enough and it is finding only one necessary element. My examples are simplified. As I said before:
I was talking with support team and all possible things were done for optimize performance of finding elements, so the rxPathes are good

Re: Caching of elements

Posted: Wed Jun 28, 2017 12:21 pm
by Vaughan.Douglas
i.vasilyev wrote:
Are you doing a FindSingle on the host each time or have you stuck the application into a variable and doing a findsingle on that?
Yes, i'm doing FindSingle on the Host each time
Will try to use your example, but not sure that it will help me because looks like a problem with a form itself(too many elements are under that form)
We're really just grasping at straws without a snapshot, but I completely understand why you aren't able to provide it. What we're trying to do is force Ranorex to limit its search area. Odklizec has a lot more experience with Ranorex, so I need to defer to his knowledge on this. I don't know for sure that my suggestion would improve performance, but utilizing a repository with rooted folders *should*.

I've never tried threading a Ranorex test, but I've thought about it. I have no idea if any of this would be thread safe and I think there are better solutions, but I'm a sucker for the big guns to to speak. If I were going to try to thread this, I'd break the searches out into Tasks (System.Threading.Tasks.Task) using the factory. I'd waitall for the search tasks to complete then put the input the data back in the main thread. My main concern would be that trying to thread the actual data input might change the UI and cause the element to become stale.

If you do go this route, I'l love for you to post your code for future reference and I'd be extremely interested in your thoughts about how it worked.

To get you started here's some junk code I hacked together from another non-Ranorex project. I'm drastically more familiar with VB .net code, so I used some converters to get this into C#. I make no guarantee or warranty as to the suitability of said sample.
Task<Ranorex.Unknown>[] myTasks = new Task<Ranorex.Unknown>[1];

            myTasks[1] == Task<Ranorex.Unknown>.Factory.StartNew(() =>
            {
                Ranorex.Unknown myElement;
                Host.Local.TryFindSingle("/form", out myElement);
                return myElement;
            })