Hi,
Thank you for the screenshot.
This is what I expected to see and my current explanation is like this:
Prerequisite statements:
-- NameMapping for Browser will match any object with ObjectType property equal to Browser;
-- NameMapping for Page will match any Browser's child object with ObjectType of 'Page' and URL property equal to tested url;
-- If some child object cannot be found for the parent one this does not cause TestComplete to trace-back and search for another parent object;
-- Expression 'Aliases.Browser.Page' using human language effectively means this: "Search for any Browser object. Then, for the found object search for the child object that matches criteria specified for Page object."
Considering the above, I think that this is what happens:
From time to time browser process that has no visible window remains in the system. For example, this can be some browser running in the background. Or even regular browser with some other but tested page been opened.
When Aliases.Browser.Page.Wait() expression is executed, TestComplete finds this browser process (Browser_A), sticks to it and starts to wait for its child Page object. As the tested page is opened in another browser process (Browser_B started via the Browsers.Item(...).Run() ) but not the one that was found, child Page object is never found for Browser_A object and thus expression fails.
The simplest way to solve this problem, especially if you prefer the concept of only one browser running in the system during test, is to check if any browser is running in the system and close it before launching a browser against tested web page.
Sample untested code for above might be like this:
var browser = Aliases.WaitNamedChild('Browser', 500); // check if any browser is running
while (browser.Exists)
{
browser.Close();
if (browser.Exists)
browser.Terminate();
browser = Aliases.WaitNamedChild('Browser', 500);
}
Browsers.Item(...).Run(url);
Hope that above will help.