Highlighted
Regular Contributor.
Regular Contributor.
5162 views

UFT 14:01: Cannot identify the object "[ Browser ]" (of class Browser).

I have an automated UFT script that runs each evening.  The purpose of the script is to login into several internal sites and capture screen shots, which are later reviewed. The script is using UFT 14.01, Chrome (63.0.3239.132 - 64bit), and running on a Windows 7 Enterprise machine.

The majority of the time the script works well. However, on intermittent occasions (weekly) an error will occur where UFT states:  "Cannot identify the object "[ Browser ]" (of class Browser)."  This usually happens early in the script, during a Browser.Sync or a Browser.Navigate command. The error is severe enough to completely kill the script's run.

Note that the script does not utilize the object repository, but rather descriptive program to define the Browser object and the Web Elements which it interacts with. For example, our Browser object is always defined as:

Set myBrowser = Browser("micclass:=Browser", "creationtime:=0")

We are struggling to determine why the failures occur, and why they are so intermittent.  In troubleshooting, we have gone so far as to use an "On Error Resume Next" during our preliminary Browser Sync: doing so, we've seen that when the script will record a failure, logging the "Cannot identify the object "[ Browser ]" (of class Browser)" error during the Sync, that it will sometimes continue to successfully navigate to the site soon after, in spite of the error!  But this is not always true.  Sometimes it will still completely halt with a navigation failure subsequent to the Browser.Sync error. It's almost as if UFT loses it's connection to the browser, but yet re-establishes it moments later.

The behavior is odd and inconsistent. If we can find the root cause and fix it, it will a huge help in stabilizing our automation.

Note that this problem has been recurring since we were on UFT 12.52 last year.  Since then, we have updated to 12.53, then 14 and now 14.01.  They problem yet remains, though. 

Some troubleshooting that we have tried, but with no resolution:

  • We have tried uninstalling/reinstalling the HPE Functional Testing Agent extension in Chrome (current extension is version 14.2.3792.0)
  • We have tried disabling/enabling the Chrome extension.
  • We have tried uninstalling UFT and reinstalling it
  • We have tried uninstalling/reinstalling Chrome. 
  • We have tried disabling/uinstalling all other extensions
  • We have tried removing the Browser.Sync altogether

Note: Our tests used to be ran via MMDRV through Task Scheduler, but we have recently moved to ALM for test execution.  This problem still persists, though, independent of the method of test execution.  Note that I have even seen the problem happen while manually executing the script through UFT, too.  It is not isolated to the script running only in automation.

Any insights or suggestions on how to resolve this issue would be most welcome! Note that we cannot move away from Descriptive Programming.  Using an Object Repository is not an option. Also, the sites we're testing/automating must be done in Chrome.

Thanks in advance!

Ron Turrentine

0 Likes
18 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Can you provide more information about how the browser is launched? So sometimes certain step failed with error "Browser object not found" and the step next to it run pass? How about trying to add some wait time after the launch step?

Thanks.

James

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Have you tried mving away from using the Set browser = method to in-line browser/page, you could also incorporate With statements to cut down on coding, something like:

With Browser("micClass:=Browser").Page("micClass:=Page")

    .Sync

End With

Mark Smith

 

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

JamesXue1982,

Thank you for your reply!  We are using the Shell.Application object to open the browser:

                    Set objBrowser = CreateObject("Shell.Application")
                    objBrowser.ShellExecute "chrome.exe""about:blank""""runas"3

Once the browser is open, that is when the script sets the browser object...

Set myBrowser = Browser("micclass:=Browser""creationtime:=0")

Note that before any of this is done, the script iterates through all of the active Windows processes, closing each chrome.exe, iexplore.exe, and firefox.exe process.  We do this to insure that the only browser that is open is the one which the script itself launched.

Also, I don't believe that I mentioned it, but the script takes a screenshot of the desktop when any error occurs.  I say this to note that it has been verified that the browser is definitely open when the error occurs.

Edit: James, sorry I realized that I did not specify the wait times that exist:

  • There is a 3 second wait after the Browser is launched and before the "Set myBrowser" command is issued. 
  • There is another 3 second wait after the Set Browser command is issued, but before the Browser.Sync takes place.
  • Finally there is then a 2 second wait before navigation is attempted.

I have experimented with wait times before, but to no avail. The error does not appear to be tied to a timing issue.  Also, opening up Chrome directly to the "about:blank" page is extremely fast. Having minimal extensions loaded definitely helps with its performance, too.

Thanks,

Ron

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Mark,

Thanks for the reply!  Although I have used With blocks before, one is not being used in this section of code.

I'm curious though: what is the reasoning behind using a With block to resolve our particular error?

Thanks again!

Ron

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

James Xue1982,

My response to your reply seems to have disappeared, so I am reposting:

We are using the Shell.Application object to open the browser:

                    Set objBrowser = CreateObject("Shell.Application")
                    objBrowser.ShellExecute "chrome.exe""about:blank""""runas"3

Once the browser is open, that is when the script sets the browser object...

Set myBrowser = Browser("micclass:=Browser""creationtime:=0")

Note that before any of this is done, the script iterates through all of the active Windows processes, closing each chrome.exe, iexplore.exe, and firefox.exe process.  We do this to insure that the only browser that is open is the one which the script itself launched.

Also, I don't believe that I mentioned it, but the script takes a screenshot of the desktop when any error occurs.  I say this to note that it has been verified that the browser is definitely open when the error occurs.

Here are the specific wait times that we are using:

  • There is a 3 second wait after the Browser is launched and before the "Set myBrowser" command is issued. 
  • There is another 3 second wait after the Set Browser command is issued, but before the Browser.Sync takes place.
  • Finally there is then a 2 second wait before navigation is attempted.

I have experimented with wait times before, but with no luck. I believe that the error does not appear to be tied to a timing issue.  Also, having the script open Chrome directly to the "about:blank" page is extremely fast. (Having minimal extensions loaded definitely helps with its performance, too).

Thanks,

Ron

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Ron,

Let me try and help as well with some suggestions. In my eyes, there are a few suspects here, by order of probability as I see it:

  1. “About:blank” can cause recognition issues. Can you open the browser on any other site?
  2. Have you tried launching the browser using “LaunchBrowser” or “SystemUtil.Run”?
  3. It may be that the lines that are closing all other browsers are causing some instabilities to the browsers themselves, if it is killing them not gracefully. Have you tried skipping this step completely?
    Also, how are you killing all processes? Using SystemUtil.CloseProcessByName?

Thanks,

Tsachi

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

My uderstanding of the With statement (which I'm not 100% on) is that UFT 'identifies' the heirarchy in the With statement so it doesn't have to keep identifying it when you use the traditional Browser(B).Page(P) .Object on every line.

Mark Smith.

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Tsachi,

Thanks so much for your reply!  I'll respond to each of your questions below...

1.) “About:blank” can cause recognition issues. Can you open the browser on any other site?

That's interesting that you should say that.  Is this a documented/known problem?  We were once opening to http://www.google.com, but I switched to about:blank just for the simple reason of speed.

This morning, after I read your reply, one of our testers reported that they were receiving the "Cannot Identify Object Browser" errors, so I went to their desk.  I actually changed the script to point to http://www.google.com from about:blank, but we still had the same issue.  I was quite disappointed. 😞

2.) Have you tried launching the browser using “LaunchBrowser” or “SystemUtil.Run”?

I have not done that, but I would definitely be willing to give it a try.  We had decided to use the Shell.application object in order to launch the browser as an admin with the "runas" designation.  But I'm willing to try all other possible routes to eliminate the problem, that's for sure!

3.) It may be that the lines that are closing all other browsers are causing some instabilities to the browsers themselves, if it is killing them not gracefully. Have you tried skipping this step completely? Also, how are you killing all processes? Using SystemUtil.CloseProcessByName?

No, we're actually using the WMIService to do it.  We're querying the Win32 processes by name and then iterating through the process collection and using the Terminate method to close each one.

Unfortunately, since this is automation and we are testing multiple applications, we cannot skip this step.  It is necessary to close out all other browsers before our script moves to the next application to test.

Thanks again for your reply, your insight is appreciated!

Ron

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Mark,

Thanks for the reply, I was curious.  I will have to remember this when working on future scripts!

Ron

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

I use the following as I had an issue with using the terminate method (can't remember what the issue was)

SystemUtil.CloseProcessByName("iexplore.exe")
SystemUtil.CloseProcessByName("firefox.exe")
SystemUtil.CloseProcessByName("chrome.exe")

Mark Smith.

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

The Sync & Navigate methods were problematic in previous versions of QTP/UFT. 

Here's a similar case, with a workaround. Check it out.

_____________________
Rajkumar Rajangam
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.