WORKING WITH QTP

TestEveryThinG

Archive for December, 2010

Sorting of Array by using VB script

Posted by rajivkumarnandvani on December 31, 2010

HAPPY NEW YEAR 🙂

Hi All ,

Sometimes while doing scripting we required sorting of array number. Here I am posting the script that will sort the number of array.

arrSample = Array(4, 6, 2, 7, 3, 5, 1)

msgbox vbCrLf & “array before”

For Each intNumber In arrSample

msgbox intNumber

Next

Function SortArray (byval arrayname)

For i = LBound(arrayname)  to  UBound(arrayname)

For j = LBound(arrayname)  to  UBound(arrayname)

If j <> UBound(arrayname)  Then

If arrayname(j) > arrayname(j + 1)  Then

TempValue = arrayname(j + 1)

arrayname(j + 1) = arrayname(j)

arrayname(j) = TempValue

End If

End If

Next

Next

SortArray = arrayname

End Function

msgbox vbCrLf & “array after”

REM calling function SortArray()

Arrayaftersort  =  SortArray(arrSample)

For Each intNumber  In Arrayaftersort

msgbox intNumber

Next

Advertisements

Posted in QTP | Tagged: , | Leave a Comment »

Connect QC through API using VB script

Posted by rajivkumarnandvani on December 20, 2010

Hi All,
Here I am mentioning the script that will connect to Quality Center. For this,your system must have QC api dll/QC client installed.

REM Define the Domain name
DomainName =”DEFAULT”

REM ‘Define the ProjectName
ProjectName =”Automation”
REM ‘ login username
UserName =”Rajeev Nandwani”
REM ‘ login password
Password =”RNSystem00″
REM ‘ Server name with Port
ServerName =”QAserver:8080″

Rem Create QC Connection Object
Set objTDConnection = CreateObject(“TDApiOle80.TDConnection.1”)
Rem Connect with server
QCServerName =”http://”&amp; ServerName &”/qcbin”
objTDConnection.InitConnectionEx QCServerName
Rem Connect with Project
objTDConnection.ConnectProjectEx DomainName, ProjectName, UserName, Password

Rem Check login Success or not

If objTDConnection.loggedin Then

msgbox “Connect successfully ”
else
msgbox “not connect with Quality Center Check username /Password/Domain name /Project Name ”
End If

Set objTDConnection = nothing

Posted in QTP | Tagged: , , | 3 Comments »

 
%d bloggers like this: