Custom Search

Sunday, January 29, 2012

Open Internet Explorer through CreateObject


Function IEOpen( strApplicationURL,bBrowser)
   Set IE=CreateObject("InternetExplorer.application")
   IE.visible=True
   IE.Navigate2 strApplicationURL ''''''''' Application URL as parameter
   IE.WindowState=Maximized
   Browser(bBrowser).sync '''''''' Application Browser Object as parameter
End function

Monday, January 23, 2012

Dictionary Object


Dictionary Object 
Dictionary Object  stores data key, item pairs. A Dictionary object stores the items in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array. 


 Advantages of using it in QTP:
1. can be used as Global variable declaration. so that any test can access the values from it in the run time.
2. You can store and retrieve any number of run time values in to dictionary.
3. It is one of the Parametrization technique we can use in QTP

we can use below methods in Dictionary Object.
1. Add Method
2. Exists Method
3. Items Method
4.Keys Method
5. Remove Method
6. Removeall Method

Add Method
=========
Dim d ' Create a variable. 
Set d = CreateObject("Scripting.Dictionary") 
d.Add "a", "Athens" ' Add some keys and items. 
d.Add "b", "Belgrade" 
d.Add "c", "Cairo"

Exists Method
=========
Dim d, msg ' Create some variables. 
Set d = CreateObject("Scripting.Dictionary") 
d.Add "a", "Athens" ' Add some keys and items. 
d.Add "b", "Belgrade"
d.Add "c", "Cairo" 
If d.Exists("c") Then 
msg = "Specified key exists." 
Else
msg = "Specified key doesn't exist."
End If

Items Method
=========
Use below code after add the values to dictionary

a = d.Items ' Get the items. 
For i = 0 To d.Count -1' Iterate the array. 
s = s & a(i) & "
" ' Create return string. 
Next

Sunday, January 1, 2012

How to close MsgBox at Runtime with QTP

Write the below line as the first-line in your script.
This will create a shell object at run-time and will be available until the test ends. If you are getting problem like, Activex Component can’t create object then use


Set sh = CreateObject(“Scripting.Shell”)

'Where ever you are having “Msgbox” replace it with the following code.
The below line will show the message content for 5 seconds (and vanishes after that).


sh.Popup “message content”, 5, “msg header”, (0+4)

How to Delete Cookies, Delete Browser temporary files, Clear Browser History with QTP Script

'WebUtil object is one of the undocumented object in QTP.
'Execute the Below statement before opening the browser to delete cookies.

Webutil.DeleteCookies

'To clear temporary Internet files
Set WshShell = CreateObject("WScript.Shell")
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8"

'To Clear Browsing History
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1"

wait (10)