BASIC QTP OPERATIONS WITH VB SCRIPT



‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
‘GET THE CURRENTLY OPENED SCRIPT NAME IN QTP WITH VB SCRIPT
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Public Function funcGetOpenedTest()

‘Create QTP Object
Set objQTP = CreateObject("QuickTest.Application")

‘Making the QTP Window Visible
objQTP.Visible = True

‘Launching the QTP Application
objQTP.Launch

            ‘Displaying the Opened Test Name
            MsgBox ("Current Test Opend in QTP : " & objQTP.Test.Name)

End Function
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
‘WHILE OPENING SCRIPT IN QTP, CHECK CURRENT SCRIPT IS SAVED. IF IT’S NOT SAVED MEANs SAVE
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Public Function funcSaveScript()

‘Create QTP Object
Set objQTP = CreateObject("QuickTest.Application")

‘Making the QTP Window Visible
objQTP.Visible = True

‘Launching the QTP Application
objQTP.Launch

            boolSave = False

            ‘Saving the Script, if its not saved
If objQTP.Test.Modified Then

            strReturnValue = MsgBox("Do you want to save """ & objQTP.Test.Name & """?", vbYesNoCancel)

            If strReturnValue = vbYes Then

                        objQTP.Test.Save

            ElseIf strReturnValue = vbNo Then

                        boolSave = False

            Else

                        WScript.Quit

            End If

End If

End Function
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
‘OPENING THE SCRIPT IN READONLY
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Public Function funcOpenScriptInReadOnly()

‘Create QTP Object
Set objQTP = CreateObject("QuickTest.Application")

‘Making the QTP Window Visible
objQTP.Visible = True

‘Launching the QTP Application
objQTP.Launch

            ‘Open script in Update Mode
            objQTP.Open strTestPath

            ‘Open Script in Read Only Mode
objQTP.Open TestPath, true

End Function
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

No comments:

Post a Comment