Tuesday, December 21, 2010

Running a test set through OTA API

‘Option Explicit

Public Sub RunTestSet(otdc, tsFolderName, tSetName, _
HostName, runWhere)

Dim TSetFact, tsList
Dim theTestSet
Dim tsTreeMgr
Dim tsFolder
Dim Scheduler
Dim nPath
Dim execStatus

‘ Get the test set tree manager from the test set factory
‘tdc is the global TDConnection object.
Set TSetFact = otdc.TestSetFactory
Set tsTreeMgr = otdc.TestSetTreeManager
‘ Get the test set folder passed as an argument to the example code
nPath = “Root\” & Trim(tsFolderName)
Set tsFolder = tsTreeMgr.NodeByPath(nPath)
If tsFolder Is Nothing Then
err.Raise vbObjectError + 1, “RunTestSet”, “Could not find folder ” & nPath
End If

‘ Search for the test set passed as an argument to the example code

Set tsList = tsFolder.FindTestSets(tSetName)

If tsList Is Nothing Then
err.Raise vbObjectError + 1, “RunTestSet”, “Could not find test set in the ” & nPath
End If

If tsList.Count > 1 Then
MsgBox “FindTestSets found more than one test set: refine search”
Exit Sub
ElseIf tsList.Count < 1 Then
MsgBox “FindTestSets: test set not found”
Exit Sub
End If
Set theTestSet = tsList.Item(1)
‘Debug.Print theTestSet.ID

‘Start the scheduler on the local machine
Set Scheduler = theTestSet.StartExecution(HostName)

‘Set up for the run depending on where the test instances
‘ are to execute.

Select Case runWhere
Case “RUN_LOCAL”
‘Run all tests on the local machine
Scheduler.RunAllLocally = True
Case “RUN_REMOTE”
‘Run tests on a specified remote machine
Scheduler.TdHostName = HostName
‘ RunAllLocally must not be set for
‘ remote invocation of tests.
‘ Do not do this:
‘ Scheduler.RunAllLocally = False
Case “RUN_PLANNED_HOST”
‘Run on the hosts as planned in the test set
Dim TSTestFact, TestList
Dim tsFilter
Dim TSTst
‘Get the test instances from the test set
Set TSTestFact = theTestSet.TSTestFactory
Set tsFilter = TSTestFact.Filter
tsFilter.Filter(“TC_CYCLE_ID”) = theTestSet.ID
Set TestList = TSTestFact.NewList(tsFilter.Text)
Scheduler.RunAllLocally = False
End Select

‘Run the tests
Scheduler.run

Set execStatus = Scheduler.ExecutionStatus

While (RunFinished = False)
execStatus.RefreshExecStatusInfo “all”, True
RunFinished = execStatus.Finished
Wend
End Sub

‘================================

Const qcHostName = “”
Const qcDomain = “”
Const qcProject = “” ‘Please define here the name of the project
Const qcUser = “” ‘Please define here the username
Const qcPassword = “” ‘Please define here the password
Dim tdc
Dim qcServer
Dim objArgs
Dim strArg
Dim strTestSet
Dim bRunCode

‘======GETTING ARGUMENTS==============
set objArgs = WScript.Arguments
If WScript.Arguments.Count<1 Or WScript.Arguments.Count>2 Then
WScript.Echo “Please enter the name of the test set”
bRunCode = False
Else
For Each strArg in objArgs
WScript.Echo strArg&” is starting…”
strTestSet = strArg
bRunCode = True
Next
End If
‘===========================================================

If bRunCode Then
qcServer = “http://” & qcHostName
qcServer = qcServer & “/qcbin”
Set tdc = CreateObject(“tdapiole80.tdconnection”)

If (tdc Is Nothing) Then
MsgBox “tdc object is empty”
End If

tdc.InitConnectionEx qcServer
tdc.Login qcUser, qcPassword
tdc.Connect qcDomain, qcProject

RunTestSet tdc, “Insert here path to the test set”, strTestSet , “Insert here the name of the machine”, “RUN_LOCAL”

‘Disconnect from the project
If tdc.Connected Then
tdc.Disconnect
End If
‘Log off the server
If tdc.LoggedIn Then
tdc.Logout
End If
‘Release the TDConnection object.
tdc.ReleaseConnection
”Check status (For illustrative purposes.)
Set tdc = Nothing
End IF

Tuesday, November 9, 2010

editing a registry file with VBScript

Option Explicit
'Declare variables
Dim WSHShell, rr, rr2, MyBox, val, val2, ttl, toggle
Dim jobfunc, itemtype
On Error Resume Next
Set WSHShell = WScript.CreateObject("WScript.Shell")
val = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools"
val2 = "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools"
itemtype = "REG_DWORD"
jobfunc = "Registry Editing Tools are now "
ttl = "Result"
'reads the registry key value.
rr = WSHShell.RegRead (val)
rr2 = WSHShell.RegRead (val2)
toggle=1
If (rr=1 or rr2=1) Then toggle=0
If toggle = 1 Then
WSHShell.RegWrite val, 1, itemtype
WSHShell.RegWrite val2, 1, itemtype
Mybox = MsgBox(jobfunc & "disabled.", 4096, ttl)
Else
WSHShell.RegDelete val
WSHShell.RegDelete val2
Mybox = MsgBox(jobfunc & "enabled.", 4096, ttl)
End If

Thursday, November 4, 2010

Schedule/execute testset run in Quality Center from Windows (VBScript)

http://the-koala-egg.blogspot.com/2008/02/scheduleexecute-testset-run-in-quality.html
-----------------
VBScript:

Dim QCConnectionSet
QCConnection = CreateObject("TDApiOle80.TDConnection")



QCConnection.InitConnectionEx "server_address" ' <--------------- Fill in server addressQCConnection.login "user", "pwd" '<------------------- FILL in user/pwd

QCConnection.Connect "domain_name", "project_name" '<----------- FILL Domain/Project

Set TSetFact = QCConnection.TestSetFactory
Set tsTreeMgr = QCConnection.TestSetTreeManager
nPath = "Root\test" '<------------- FILL IN PATH TO TESTSET

Set tsFolder = tsTreeMgr.NodeByPath(nPath)
If tsFolder Is Nothing Then
msgbox "error"

End If


Set tsList = tsFolder.FindTestSets("name_of testset") '<------- FILL IN NAME OF TESTSET
If tsList.Count > 1 Then
MsgBox "FindTestSets found more than one test set: refine search"
ElseIf tsList.Count <>
MsgBox "FindTestSets: test set not found"
End If


Set theTestSet = tsList.Item(1)
Set Scheduler = theTestSet.StartExecution("")
Scheduler.RunAllLocally = True
Scheduler.HostTimeOut = 100000
Scheduler.runSet execStatus = Scheduler.ExecutionStatus

RunFinished = False
while RunFinished = False
execStatus.RefreshExecStatusInfo "all", True
RunFinished = execStatus.Finished

wend

QCConnection.Disconnect
QCConnection.Logout
Set QCConnection = Nothing

---------------

Wednesday, October 27, 2010

creating a new database using vbscript

Set oConn = CreateObject( "ADOX.Catalog" )



oConn.Create "Provider = Microsoft.Jet.OLEDB.4.0; " & _

"Data Source = new_db.mdb"

how to retreive data from a database

Dim oConn, oRst, oField

Dim sql



set oConn = CreateObject("ADODB.Connection")

oConn.Open "QT_Flight32"

set oRst = CreateObject("ADODB.recordset")

oRst.Open "Select * from Orders", oConn

Do Until oRst.EOF

For each oField in oRst.Fields

Print oField.Name & " = " & oField.Value

Next

Print String( 20, "-" )

oRst.MoveNext

loop



oRst.close

oConn.close

http://www.advancedqtp.com/knowledge-base/qtips/databases-id44/adodb/display-records/

Tuesday, October 26, 2010

automating google earth using QTP

There is good article mentioned in advancedqtp.com. It says that it can be automated and here is the URL
http://www.advancedqtp.com/knowledge-base/articles/environment-techniques-id15/web-id34/automating-google-earth/

Can we test mobile applications in the mobile phone

The question is discussed in several forums here I am giving the URLs of the respective forums.

http://www.jamosolutions.com/documents/meuxqtp.html

http://experitest.com/support/tutorial/how-to/set-up-new-project/connect-an-external-device-e-g-android/ - advancedqtp.com