Tuesday

QTP - Scripts

'===============================
''''''''''''''''''Descriptive Program - To get the Gmail link - Start
'==============================
'
'SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","","C:\Documents and Settings\shukr02","open"
''Browser("browser").Page("webcalendar").weblist("CalendarSource").Select "#1"
''
''wait 2
'set odesc =Description.Create()
'odesc("micclass").Value = "Link"
'Dim flag
'flag=false
''Set Links = browser("browser").Page("webcalendar").ChildObjects(odesc)
''Set Links = browser("browser").Page("webcalendar").ChildObjects(odesc)
'Set Links=Browser("Google").Page("Google").ChildObjects(odesc)
'
'For i=0 to Links.Count-1
'val = Links(i).getROproperty("text")
'If val="Gmail" Then
' Links(i).Click
' flag= true
'End If
'
'next
'
'If flag=true Then
'
'Reporter.ReportEvent micPass,"pass","Gmail link found"
'
'End If
'===============================
''''''''''''''''''Descriptive Program - To get the Gmail link - End
'==============================
'===============================
''''''''''''''''''Mouse Operation - Start
'==============================

'
'SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","","C:\Documents and Settings\shukr02","open"
'Browser("Google").Page("Google").WebEdit("q").Set "wiki"
'Browser("Google").Page("Google").WebEdit("q").Submit
'Browser("Google").Page("wiki - Google Search").Sync
'Browser("Google").Page("wiki - Google Search").WebEdit("q").Set "WebPackage"
'
'Setting.WebPackage("ReplayType") = 2
'Browser("Google").Page("wiki - Google Search").WebEdit("q").Click ,, micRightBtn
'
'
'Set DeviceReplay = CreateObject("Mercury.DeviceReplay")
'
'DeviceReplay.KeyDown VK_CONTROL
'
'DeviceReplay.PressKey VK_A
'deviceReplay.SendString "Y umlaut: "
'
'DeviceReplay.KeyUp VK_CONTROL
'
'
'
'wait 2
'Browser("Google").Page("wiki - Google Search").WebEdit("q").Click ,, micLeftBtn
'wait 2
'
'Browser("Google").Page("wiki - Google Search").WebEdit("q").Click ,, micRightBtn
'
'Setting.WebPackage("ReplayType") = 1
'
'
'Browser("Google").Page("wiki - Google Search").WebEdit("q").Set ""

'===============================
''''''''''''''''''Mouse Operation Close
'==============================

'

'************************************************************************************************************************
'Description: - Migrate QTP Script from VA.x to VA+.x - START
'From QTP help ("Convert a Set of Tests from an Older QuickTest Version to the Current Version"
'example in Open Method of Application object):
'
'This example specifies a folder in which tests from an older QuickTest version are
'stored and then loops through each test in the folder (and its subfolders) to open
'each one and save it in the current version format.
'
'************************************************************************************************************************
'
'Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
'Dim filesys
'Dim maindir
'Dim testCol
'Dim checkfolder
'
'' Create the QuickTest Professional object
'Set qtApp = CreateObject("QuickTest.Application")
'qtApp.Launch
'qtApp.Visible = True
'
'' Get the collection of test scripts
'Set filesys = CreateObject("Scripting.FileSystemObject")
'
'' TO DO: Sepecify the test script directory....
'Set maindir = filesys.GetFolder("C:\temp")
'Set testCol = maindir.SubFolders
'
'' Loop through each test in the collection
'For Each fl In testCol
'
' ' Verify the folder is a QTP test
' checkfolder = fl.Path & "\Action0"
' If (filesys.FolderExists(checkfolder)) Then ' The folder is a QTP test folder
'
' ' Convert test
' qtApp.Open fl.Path, False, False
'
' ' wscript.sleep 1000
'
' ' Save converted test
' qtApp.Test.Save
'
' End If
'Next
'
'qtApp.Quit
'
'' Release the File System Objects
'Set testCol = Nothing
'Set maindir = Nothing
'Set filesys = Nothing
'
'' Release the QuickTest Professional application object
'Set qtApp = Nothing
'************************************************************************************************************************
'Description: - Migrate QTP Script from VA.x to VA+.x - END
'
'************************************************************************************************************************


'************************************************************************************************************************
'Description: - Enviorment Variable -START
'
'************************************************************************************************************************

'
'
'
'
'
' Testing
'
' 25 Yellow Road
'
'

'
'
'
' Address2
'
' Testing
'
'

'
'
'
' Name
'
' John Brown
'
'

'
'
'
' testing
'
' 1-123-12345678
'
'

'
'


'Public qtp_App
'Set qtp_App = GetObject("","QuickTest.Application")
'qtp_App.Test.Environment.LoadFromFile("c:\Tests\test.xml")
'Msgbox qtp_App.Test.Environment.value("Testing")
'
'
'EnvXMLfile="c:\Tests\test.xml"
'Set qtp_App1= CreateObject("QuickTest.Application")
''qtp_App.launch
'qtp_App1.Test.Environment.LoadFromFile(EnvXMLfile)
'Frommail = qtp_App1.Test.Environment.value("Testing")
'msgbox Frommail
''qtp_App.Quit
''Set qtp_App=Nothing

'************************************************************************************************************************
'Description: - Enviorment Variable -END
'
'************************************************************************************************************************


'************************************************************************************************************************
'How can i make some rows colored in the data table? - START
'
'************************************************************************************************************************

Set xlApp=Createobject("Excel.Application")
set xlWorkBook=xlApp.workbooks.add
set xlWorkSheet=xlWorkBook.WorkSheets.add

'Every where on net it is given .WorkSheet instead of .WorkSheets and failing ... take care

xlWorkSheet.Range("A1:B10").interior.colorindex = 34 'Change the color of the cells
xlWorkSheet.Range("A1:A10").value="text" 'Will set values of all 10 rows to "text"
xlWorkSheet.Cells(1,1).value="Text" 'Will set the value of first row and first col

rowsCount=xlWorkSheet.Evaluate("COUNTA(A:A)") 'Will count the # of rows which have non blank value in the column A
colsCount=xlWorkSheet.Evaluate("COUNTA(1:1)") 'Will count the # of non blank columns in 1st row

xlWorkbook.SaveAs "C:\Test.xls"
xlWorkBook.Close
Set xlWorkSheet=Nothing
Set xlWorkBook=Nothing
set xlApp=Nothing

'************************************************************************************************************************
'How can i make some rows colored in the data table? - END
'
'************************************************************************************************************************

'************************************************************************************************************************
'How to connect database - START
''''''How to connect to a database?
'************************************************************************************************************************
' Const adOpenStatic = 3
' Const adLockOptimistic = 3
' Const adUseClient = 3
' Set objConnection = CreateObject("ADODB.Connection")
' Set objRecordset = CreateObject("ADODB.Recordset")
' objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=;PWD="
' objRecordset.CursorLocation = adUseClient
' objRecordset.CursorType = adopenstatic
' objRecordset.LockType = adlockoptimistic
' ObjRecordset.Source="select field1,field2 from testTable"
' ObjRecordset.ActiveConnection=ObjConnection
' ObjRecordset.Open 'This will execute your Query
' If ObjRecordset.recordcount>0 then
' Field1 = ObjRecordset("Field1").Value
' Field2 = ObjRecordset("Field2").Value
' End if
'

'************************************************************************************************************************
'How to connect database - END
'************************************************************************************************************************

'Dim Exl_Obj
Set Exl_Obj = CreateObject("Excel.Application")
Exl_Obj.visible = True
Set WB_Obj_1 = Exl_Obj.Workbooks.Open("C:\Sat1.xls")
Set WB_Obj_2 = Exl_Obj.Workbooks.Open("C:\Sat2.xls")
Set WS_Obj_1 = WB_Obj_1.Worksheets(1)
Set WS_Obj_2 = WB_Obj_2.Worksheets(1)

'Set cell = WS_Obj_1.Cells

For Each cell In WS_Obj_1.UsedRange
if cell.Value <> WS_Obj_2.Range(Cell.Address).Value Then
cell.Interior.ColorIndex = 6
Else
cell.Interior.ColorIndex = 0
End if
Next
EXl_Obj.workbooks("Sat1.xls").save
EXl_Obj.workbooks("Sat1.xls").Close
EXl_Obj.workbooks("Sat2.xls").save
EXl_Obj.workbooks("Sat2.xls").Close
Exl_Obj.Application.Quit
Set Exl_Obj = nothing

'--------------------------------

No comments:

Post a Comment