We all know that “analog” is widely considered a dirty word when it comes to QTP scripting. It is very sensitive to changes in the environment in which the script is executed, such as objects that were moved in the window, changes to screen resolution or changes to window size & position. We can’t do much when it comes to the first problem, but there is a simple trick that should eliminate the problems caused by changes to the window size and position, and in some cases screen resolution;

When you start recording in analog mode, select the option to record relative to the window. This will eliminate some of the window position problems but is still prone to failure. To (mostly) eliminate these problems, record a “Move” step and a “Resize” step for the window, e.g.:

Window(“Paint”).Move 0,0
Window(“Paint”).Resize 859,632

This is good and well if we are working with Windows applications, but what about web browsers? There are no "Move" or "Resize" methods for the Browser class. In this case you can invoke the "Move" and "Resize" methods using the browser's native Window class:

pagetitle = Browser("YourBrowser").GetROProperty("title")
Window("regexpwndclass:=IEFrame","title:=" & pagetitle).Move 0,0
Window("regexpwndclass:=IEFrame","title:=" & pagetitle).Resize 859,632

This will ensure that the window has a constant size and position every time the script is executed, and in some cases this may even eliminate issues caused by differences in screen resolution. When pop-up windows or dialogs appear it’s probably a good idea to exit out of analog mode and record a resize and/or move of the window / dialog before continuing in the analog mode. Having said that, analog mode should only be used in cases when normal or low level recording does not work, and a pop-up window should not have this problem.

Tech tips from JDS


In other words, I got the error Ken Palmer mentions too, but I didn’t look for the title of the browser or the Iframe.

The above code works with IE 8 and ATP 10.

This of course still does not help if your QTP code runs on a screen with a different resolution than the one you recorded on.

This does basically work.

For QTP 10 the following works:

With Browser(“Browser”)
.Navigate “http://www.google.com/maps”
.Navigate “http://www.google.com/mapfiles/home3.html”,”vp”
End With

‘ switch to low level recording mode here.

With Window(“Windows Internet Explorer”)
.Resize 1024, 860 ‘ horizontal, vertical
.WinObject(“Internet Explorer_Server”).Click 216,17
End With

‘ switch out of low level recording (if you want)

To get the native Window class you can temporarily turn on low level recording. After recording go to expert mode and type in the resize method. You will see it in intellisense.

Good luck.

Ken Palmer

This looked promising. Can’t get it to work in QTP 10/ XP /IE 7. Can’t find object “Window” [of class “Window”]. Rats.