Page 1 of 1

takes long time to identify the object

Posted: Tue Aug 21, 2012 8:17 pm
by omayer
it does take 50sec to find the imgtag, what else could i try to reduce the timing, if i changed to 40sec it can't identify the object
{
bool found = true;
WebDocument webDocument ="/dom[@page='index.cfm']";
ImgTag findCycleId;
found = webDocument.TryFindSingle(".//img[@title='Invoice Cycle ID']",50000, out findCycleId);
findCycleId.Click();
}
Thank you In advance

Re: takes long time to identify the object

Posted: Tue Aug 21, 2012 11:03 pm
by Ciege
Well, you are rooted at your DOM object and searching down. If your imgtag is buried deep in the web page or there are a lot of other elements in the webpage it can take quite some time to search for that imgtag.

You can change your root from where you begin searching at. Such as if the imgtag is in a specific container you can root to that container.

Re: takes long time to identify the object

Posted: Wed Aug 22, 2012 2:30 pm
by omayer
Thank you Ciege, will do search on container level.

Re: takes long time to identify the object

Posted: Wed Aug 22, 2012 5:35 pm
by omayer
Hi Ciege,
Would you please give some code sample for not to search from the root level since can't find the object when webdoc was not used as root , thank you in advance

Re: takes long time to identify the object

Posted: Wed Aug 22, 2012 5:48 pm
by Ciege
From you existing code snippet...
Change your

Code: Select all

WebDocument webDocument ="/dom[@page='index.cfm']";
to a lower level element, such as a container in your DOM object...

Then change the

Code: Select all

found = webDocument.TryFindSingle(".//img[@title='Invoice Cycle ID']",50000, out findCycleId);
to use the element you want to root from (from above)... Replace the webDocument.TryFindSingle to yourElement.TryFindSingle.

Re: takes long time to identify the object

Posted: Wed Aug 22, 2012 5:51 pm
by Ciege
Keep in mind... the element you are searching for must be a child or descendant of the element you are rooting your search from...

Re: takes long time to identify the object

Posted: Wed Aug 22, 2012 6:24 pm
by omayer
thank you Ciege, going to try it now