TryFind is Slow : Automation API

TryFind is Slow

Class library usage, coding and language questions.

TryFind is Slow

Postby Pixi6s » Fri Sep 16, 2011 6:12 pm

Hello,

I have been using TryFind and Find and both are really slowing down my automation. I needed to start using them over the repository for some areas because the web site development keeps changing the specific DIV that some items are in and I can't keep up with it.

I am curious if I am missing a better method to use. I'd like one where I give it an xpath to start from, and a xpath of what to find. That way i can just skip the few DIVs that are causing the issue without it having to search the entire page as it is doing with the tryfind.

If anyone know of this method or of another solution to speed this up and can supply a code snippet that would be great!

I am using Ranorex version 3.0.0.4 in C#.

Thanks much
Pixi6s
 
Posts: 86
Joined: Tue Jun 28, 2011 9:57 pm

Re: TryFind is Slow

Postby Ciege » Fri Sep 16, 2011 7:15 pm

You can do a find on the root div and get that as your starting point. Then, using the root div object, find the objects that live below that div. Therefore, you are not having to search the entire AUT but from your starting point downwards only.

I.e.
MyDiv = MyDivXpath
MyObject1 = MyDiv.FindSingle(".//MyCriteria1")
MyObject2 = MyDiv.FindSingle(".//MyCriteria2")
MyObject3 = MyDiv.FindSingle(".//MyCriteria3")

Or if as you say, the DIV keeps changing, you can change your root to one parent up from that DIV and start there rather than from the root of the entire AUT.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: TryFind is Slow

Postby omayer » Fri Sep 16, 2011 9:28 pm

Hi Ciege,
MyDiv = MyDivXpath (is this xpath coming from repository or on runtime?)
Thanks in advance.
Tipu
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: TryFind is Slow

Postby Ciege » Fri Sep 16, 2011 10:14 pm

omayer wrote:Hi Ciege,
MyDiv = MyDivXpath (is this xpath coming from repository or on runtime?)
Thanks in advance.


Your choice...
I do it at runtime, you can do it from the repo... Whatever works for your situation.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: TryFind is Slow

Postby omayer » Mon Sep 19, 2011 2:29 pm

Thank you Ciege
Tipu
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: TryFind is Slow

Postby Pixi6s » Wed Sep 28, 2011 5:39 pm

So I finally had a chance to try and implement this, and I did get it to work, using DivTag instead of Top level WebDocument, but it wasn't any faster. It still takes about 55 seconds for the TryFind to complete which is actually a few seconds longer (takes about 50-51 with webdoc). So bummer. Any thoughts around this? Would you find it surprising that it is not any quicker?

Thanks
Pixi6s
 
Posts: 86
Joined: Tue Jun 28, 2011 9:57 pm

Re: TryFind is Slow

Postby Ciege » Wed Sep 28, 2011 5:48 pm

Can you post your code and surrounding code that is doing the find?
Also, can you post your RanorexSpy snapshot?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: TryFind is Slow

Postby Pixi6s » Wed Sep 28, 2011 6:05 pm

This is the inital
Code: Select all
           
WebDocument wd = repo.RBCorp.BasePath.ToString();  //dom[@domain=$domain]
Report.Log(ReportLevel.Info, "Auto", "Evaluate Fine Print Link");
Ranorex.ATag finePrint = wd.FindSingle("//div[@id='tabs-3']/a[@innertext~'^.*See the rules']");


I modified it to
Code: Select all
DivTag wd = repo.RBCorp.BasePath.ToString() + "/" + repo.RBCorp.DetailDetails.BasePath.ToString(); //dom[@domain=$domain]/body/form/div[5]/div[@id='bd']/div[2]/div/div[1]/div
Report.Log(ReportLevel.Info, "Auto", "Evaluate Fine Print Link");
Ranorex.ATag finePrint = wd.FindSingle("//div[@id='tabs-3']/a[@innertext~'^.*See the rules']");


Let me know if this is not the snap shot you were expecting.
Attachments
spy.JPG
spy.JPG (170.83 KiB) Viewed 120 times
Pixi6s
 
Posts: 86
Joined: Tue Jun 28, 2011 9:57 pm

Re: TryFind is Slow

Postby Ciege » Wed Sep 28, 2011 6:18 pm

For giggles, try adding a '.' before your '//' in your FindSingle. See if that helps...

Change
Code: Select all
Ranorex.ATag finePrint = wd.FindSingle("//div[@id='tabs-3']/a[@innertext~'^.*See the rules']");


to
Code: Select all
Ranorex.ATag finePrint = wd.FindSingle(".//div[@id='tabs-3']/a[@innertext~'^.*See the rules']");
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: TryFind is Slow

Postby Pixi6s » Wed Sep 28, 2011 6:54 pm

Oh my! Thank you Ciege! The Div TryFind went from 55s to about 30ms and even the webdoc call went from 50s to just about 1s!!

Pesky little dot. I will have to be better about posting my code in the future.

Thank you much!
Pixi6s
 
Posts: 86
Joined: Tue Jun 28, 2011 9:57 pm

Re: TryFind is Slow

Postby Ciege » Wed Sep 28, 2011 7:03 pm

Good deal! Glad it worked for you...

While not always necessary, sometimes it really helps to see the code so we can all make slightly more intelligent suggestions...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests

cron