Ok, thanks for the help. It uses just ObjectType.
Its weird. A browser window always appears, but sometimes fails to load the provided URL page.
- I see the issue come and go when using firefox. The fact that it works for the most part, tells me its not a firefox browser config issue.
- I've never seen the issue when working with Edge or Chrome. So I assume the network and webserver is getting/responding to the request ok.
It shouldn't happen in the first place - But after launching, maybe I should create a dynamic wait to check for the login page and while it fails to exist ask the browser to navigate to the url again.
thanks for the assistance.
Thank you for the screenshot.
This is what I expected to see and my current explanation is like this:
-- 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
browser = Aliases.WaitNamedChild('Browser', 500);
Hope that above will help.
There is still something else going on. What you suggested (closing down browsers), I already had in place.
1) We current use the eventhandler = TestEngineEvents_OnStartTestCase
function TestEngineEvents_OnStartTestCase(Sender, StartTestCaseParams)
Note: I added the aqUtils.Delay("2000"); statement just last night to see if there was an additional timing issue. But didn't fix it.
2) When I run a series of tests with Firefox I see results like the following.
Everything worked fine for a couple tests but then ran into same issue:
While it was in this state, I looked at Taskmgr. The Firefox applications does have multiple sub-processes.
.Close() command not always ends the process. Especially with browser process. Thus I would try approach with .Terminate() that is described in the help article for the Close() method. (I also mentioned it in my previous reply.)
Are all your tests marked as test cases? Maybe OnStartTest event is better?
> The Firefox applications does have multiple sub-processes.
This is a usual behavior of modern browsers.
One more comment as for the code of closeAllBrowsers2() function:
a) As it is documented, .Close() method does not return information of whether or not the process was actually closed. Thus, the next message (Log.Message("...Closed a browser.") ) is misleading as it confirms the action that possibly was not completed.
Still debugging, please don't close as of yet.
@bhcommunity1 did Alex's advice help?
I'll mark his suggestion as a temporary solution, please do share your results here!