Custom Search

Tuesday, May 10, 2011

Upload attachments to Quality Center Current Run Test from QTP

Function UpLoadAttachmentToQC(FilePath)
   Set ObjCurrentTest = QCUtil.CurrentTest.Attachments
   Set ObjAttch = ObjCurrentTest.AddItem(Null)
   ObjAttch.FileName = FilePath
   ObjAttch.Type = 1
   ObjAttch.Post
   ObjAttch.Refresh
End Function

FilePath=”C:\abc.vbs”

Call UpLoadAttachmentToQC(FilePath)






Close QTP after execution from VBS Files

Private Function CloseQTP
        Set objWMIService = GetObject(“winmgmts:\\.\root\CIMV2″)
        Set colProcess = objWMIService.ExecQuery (“Select * from Win32_Process Where Name =  QTPro.exe’”)
       For Each objProcess in colProcess
          objProcess.Terminate()
      Next
     Set objWMIService = Nothing
    Set colProcess = Nothing
End FunctionCall CloseQTP

Adding Library files to QTP at run time

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable

Dim qtLibraries 'As QuickTest.TestLibraries ' Declare a test's libraries collection variable
Dim lngPosition
' Open QuickTest
Set qtApp = CreateObject( QuickTest.Application ) ' Create the Application object
qtApp.Launch ' Launch QuickTest
qtApp.Visible = True ' Set QuickTest to be visible
' Open a test and get its libraries collection
qtApp.Open C:\Test1 False False ' Open a test
Set qtLibraries = qtApp.Test.Settings.Resources.Libraries ' Get the libraries collection object
' Add Utilities.vbs if it's not in the collection
If qtLibraries.Find( C:\sai1.vbs ) = -1 Then ' If the library cannot be found in the collection
     qtLibraries.Add C:\sai1.vbs 1 ' Add the library to the collection
End If

Friday, May 6, 2011

Retrive multiple column and Rows values from Excel sheet with Query

myarray=GetDataFromExcel("C:\QTPExcelTest\Excel.xls","WCH","ColName1,ColName2","VisitGroup='Prenatal Visit'")
RowCount=UBound(myarray,2)
colVal=0
For c=0 to colVal
   For r=0 to RowCount
       MsgBox myArray(r,c)
   Next
Next

Function GetDataFromExcel(strPath, strSheet, strRqfields,strWhereClause)
Dim cn
''Create connection to Excel 2003 sheet
Set cn = CreateObject("ADODB.Connection")
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.ConnectionString = "Data Source="&strPath&";" &"Extended Properties=Excel 4.0;"
cn.Open
If err.number <> 0 Then
   Print Err.number
End if
''' Execting Query
Query = "Select "& strRqfields &" FROM [" & StrSheet & "$] where "& strWhereClause
Set rs = CreateObject("ADODB.recordset")
Set rs = cn.Execute(Query)
If Not Rs.EOF Then
   myArray = Rs.GetRows()
End If
GetDataFromExcel=myArray
rs.close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Function

Sunday, January 9, 2011

How to add all array values without using “&” symbol?

Using Join method, add all array value to one string as below.

Dim Mystring
Dim Myarray(2)
Myarray(0)="Mr."
Myarray(1)="Jhon"
Myarray(2)="Deo"

Mystring=join(Myarray)
msgbox Mystring

Difference between Smoke and Sanity Testing?

Smoke Testing : - Smoke Testing done to ensure that whether the build can be accepted for further software testing or not. Basically, it is done to check the stability of the build received for software testing.

Sanity testing : - After receiving a build with minor changes in the code or functionality, check whether it rectified the  bugs or issues and any other bugs is introduced by the changes. and also test some of the functionalities in depth to ensure that whether the requirements are met or not.

Sunday, January 2, 2011

Get the repeated character in one string

Function GetCharCount(strChar,strSearchIn)
    dim intCounter
    for intCounter = 1 to len(strSearchIn)
         if Mid(strSearchIn,intCounter,1)=strChar then
             GetCharCount=GetCharCount+1
         end if
    next
End Function
msgbox GetCharCount("s", "this is a string")

======Second method=========
str="this is a string"
msgbox Len(str)-Len(Replace(str,"s",""))