Launching Internet Explorer (IE) - QTP

Internet explorer can be launched as an application or by using its COM library. Let's see how both of these techniques can be used.

Method 1

'Launch IE as an application using a QTP method
SystemUtil.Run "iexplore.exe"
'Launch IE using the WScript shell
Set oShell = CreateObject("WScript.Shell")
oShell.Run "iexplore.exe"

Method 2

'Create IE application COM object
Set oIEApp = CreateObject("InternetExploxer.Application")
'By default the APP is not visible, so make it visible oIEApp.
Visible = True
'Navigate to a web site
oIEApp.Navigate2 "http://www.mywebsite.com"

When we launch IE using the 2nd method, we can use the IE Window's handle to reference the browser as a QTP Test object using the following code:

'Get the handle of the IE window
iehWnd = oIEApp.HWND
'Close the Browser using QTP test object
Browser("hwnd;="&iehWnd).Close

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

QTP Topics