Caching of elements

Class library usage, coding and language questions.
i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Caching of elements

Post by i.vasilyev » Tue Jun 27, 2017 2:37 pm

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
Last edited by i.vasilyev on Tue Jun 27, 2017 3:15 pm, edited 2 times in total.

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Caching of elements

Post by Vaughan.Douglas » Tue Jun 27, 2017 2:43 pm

I believe Ranorex caches objects by default.

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

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Caching of elements

Post by i.vasilyev » Tue Jun 27, 2017 3:09 pm

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

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Caching of elements

Post by Vaughan.Douglas » Tue Jun 27, 2017 3:22 pm

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.
Doug Vaughan

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Caching of elements

Post by i.vasilyev » Tue Jun 27, 2017 3:28 pm

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.

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Caching of elements

Post by Vaughan.Douglas » Tue Jun 27, 2017 5:34 pm

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");
Doug Vaughan

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Caching of elements

Post by i.vasilyev » Tue Jun 27, 2017 7:13 pm

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)

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Caching of elements

Post by i.vasilyev » Wed Jun 28, 2017 8:50 am

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?

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

Re: Caching of elements

Post by odklizec » Wed Jun 28, 2017 9:06 am

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

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Caching of elements

Post by i.vasilyev » Wed Jun 28, 2017 9:18 am

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

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Caching of elements

Post by Vaughan.Douglas » Wed Jun 28, 2017 12:21 pm

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;
            })
Doug Vaughan