IE Launched using Systemutil.

Internet Explorer – Play Around…IE Launched using Systemutil

How Do I deal with this now!

 One strange question someone asked me is about handling IE operations using VBScript , the question was about navigating to a different URL in IE if it was launched using Systemutil and we don’t want to use QTP’s feature for recognising the window? Although it sounds a little weird that why would someone launch IE using Systemutil  if further actions  like going forward, going backward or retrieving information about addressbar are required to be performed on IE after  its launch or even if it’s been done so, why wouldn’t we use QTP for operating some action on it. But I believe that every question gives you a space to thing differently or something that you would have never thought otherwise.

 Let us first discuss the  way to launch IE in case you need to perform functions like navigating to several URL, going forward, going backward or retrieving information about addressbar.The easiest way to do such things is using IE’s COM object. Following piece of code demonstrates the usage of IE com object.

 

‘Author : Bharat Kakkar

‘Site: www.Technodivine.com

 ‘Creating an instance of IE

Set oIE=CreateObject(internetexplorer.application“)

 ‘Displaying the Browser

oIE.Visible=True

 ‘Navigating to a specific URL

oIE.Navigate(“http:\\www.technodivine.com”)

Similarly, you may perform other operations like GoHome, GoSearch, Refresh, GoBack, GoForward, Quit etc.

Instead, if you have used Systemutil to Launch the browser it might not
be able to perform the aforesaid operations, but thanks to the technology there
is always a workaround if no solution is available, let us see how.

# Using Shell Object

 

‘Author : Bharat Kakkar

‘Site: www.Technodivine.com

‘#############################################

creating a scenario -Prerequisite

‘# IE window exist with URL google.co.in

‘# you may create a scenario manually and omit the following line

systemutil.Run“c:\Program
Files\Internet Explorer\iexplore.exe”,”http://www.google.co.in/”

wait for IE to launch

Wait(5)

‘#############################################

‘Creating an instance of IE

Set oShellApp=CreateObject(Shell.application“)

Set
oWindows=oShellApp.Windows

‘Navigating through all windows (IExplorer/Explorer)

For Each itmWindow In oWindows

         If InStrrev(ucase(itmWindow.fullname),”IEXPLORE.EXE”)Then

                ‘Identify your window using Locationname(Title of you page)and URL

                 If itmWindow.Locationname=”Google” And itmWindow.LocationURL=”http://www.google.co.in/”
Then

                          itmWindow.navigate(“http:\\www.technodivine.com”)

                 End if

         End if

Next

 

If you have already a geek about QTP / VBScript you might be thinking some other way to resolve the same, there might be several other ways to do this but I would surely like to answer one of the many questions asked while discussing this issue, can’t we use GetObject function to retrieve the instance of IE and work on it.

 

The Answer is No, indeed. GetObject looks “Windows ROT” (a name given to phenomena of getting a program’s COM registered at the time of installation) to fetch the information of available COM objects but unlike other Programs IE doesn’t register itself in “Windows ROT”, as IE is already a part of Windows.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s