WaitForDocumentLoaded() Method and ElementNotFoundException

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
SvenP
Posts: 3
Joined: Fri Oct 09, 2009 8:31 am

WaitForDocumentLoaded() Method and ElementNotFoundException

Post by SvenP » Thu Oct 15, 2009 8:35 am

Hello,

our company is evaluating Ranorex for Website (our created Websites, Webshops) GUI Tests . It´s a fine tool and most tests run well, BUT there is a main problem that occurs often.
I use WaitForDocumentLoaded(); after every performClick() method. But Ranorex dont wait long enough for the Page, so i get an ElementNotFoundException. The other Option is to use Delay.Ms();, but it´s not a good solution. So why does WaitForDocumentLoaded() not work correctly all the time. Sometimes it works, but when the page needs too much time for loading, the method doesnt work.

Example:

Code: Select all

repo.WebDocumentZeitschriften_Abopool.Warenkorb.PerformClick();
repo.WebDocumentWarenkorb_Minus_Zeitschr.Self.WaitForDocumentLoaded();

Report.Info("Es wird überprüft, ob die Zeitschrift '" + s + "' im Warenkorb liegt");
ImgTag InhaltWarenkorb = repo.WebDocumentWarenkorb_Minus_Zeitschr.SomeDivTag.FindSingle(".//img[@title='" + s + "']");
The Problem is that WebDocumentWarenkorb_Minus_Zeitschr wasnt found. if i use delay instead of repo.WebDocumentWarenkorb_Minus_Zeitschr.Self.WaitForDocumentLoaded(); it works. Sometimes it also work with WaitForDocumentLoaded() @ this example. Itßs a strange behaviour.

Thx for the help

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: WaitForDocumentLoaded() Method and ElementNotFoundException

Post by Support Team » Thu Oct 15, 2009 10:41 am

The problem here is that the WaitForDocumentLoaded method is not even called if you get an ElementNotFoundException for the repo.WebDocumentWarenkorb_Minus_Zeitschr repository item. When you try to get the repo.WebDocumentWarenkorb_Minus_Zeitschr.Self repository item, Ranorex will search for an element with the path you specified for it, e.g. for a document with the specified title.

There are two ways how you can make your code work:
  1. Increase the Search Timeout of the repo.WebDocumentWarenkorb_Minus_Zeitschr repository item.
  2. If both repo.WebDocumentZeitschriften_Abopool and repo.WebDocumentWarenkorb_Minus_Zeitschr correspond to the same browser (tab), you can call WaitForDocumentLoaded on the previous web document, too, i.e. on the repo.WebDocumentZeitschriften_Abopool repository item.
Regards,
Alex
Ranorex Support Team
.
Image

SvenP
Posts: 3
Joined: Fri Oct 09, 2009 8:31 am

Re: WaitForDocumentLoaded() Method and ElementNotFoundException

Post by SvenP » Thu Oct 15, 2009 12:53 pm

Hello,

thx for the clue. i think searchtimeout will solve the problem, but can i use this function also for variables that are not in the repository. because sometimes i need not hard coded values like this

Code: Select all

public static WebDocument Zeitschriften;
....

Zeitschriften = "/dom[@caption~'^" + x3 + y2 + "']";

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: WaitForDocumentLoaded() Method and ElementNotFoundException

Post by Support Team » Thu Oct 15, 2009 1:15 pm

You can, use the following syntax:
Zeitschriften = Host.Local.FindSingle("/dom[@caption~'^" + x3 + y2 + "']", 5000);
Regards,
Alex
Ranorex Support Team
.
Image

SvenP
Posts: 3
Joined: Fri Oct 09, 2009 8:31 am

Re: WaitForDocumentLoaded() Method and ElementNotFoundException

Post by SvenP » Thu Oct 15, 2009 1:30 pm

thanks a lot. i will try this.