This action might not be possible to undo. Are you sure you want to continue?
Download QTP add in from QC add ins section 3.YOu will find the QC symbol in the QTP 4.Double click on the QC Symbol 5.Enter the link of QC 6.Domain name and Project name 7.IF you want to connect o qc automatically when QTP is opened you have an option you can select that . How to connect to QC by VB scripting in QTP Dim QCConnection Set QCConnection = CreateObject("TDApiOle80.TDConnection") QCConnection.InitConnectionEx "http://yourserver/qcbin" QCConnection.login "login", "password" QCConnection.Connect "Domain", "Project" Uploading a local file into QC thru QTP script ################################################### #################### 'Function :AttachToQC 'Date : 17/09/2007 'Author : Gokul Putta 'Purpose :This function is used to attach the file to QC from file system 'Remarks : 'Inputs :strQCPath --> path of the folder in the QC to attach the file (should start from Subject\) 'strFileSystemPath --> path of the file to be attached to QC in the filesystem 'Change History : 'Date Author Change Description '################################################### ################### Public Function AttachToQC(strQCPath,strFilesystemPath) Set QCConnection = QCUtil.QCConnection Set treeManager = QCConnection.TreeManager ' Specify the local path to the file. LocalFilePath = strFilesystemPath ' Specify the Quality Center path to the desired folder FolderName = strQCPath Set node = treeManager.nodebypath(FolderName) set att = node.attachments Set atta = att.AddItem(Null) atta.FileName = LocalFilePath atta.Type = 1 atta.Post() End Function
Integration to QTP with Quality Centre - Test Director Description An object that enables you to manage the Quality Center connection and retrieve the TDOTA object, which provides full interaction with Quality Center. Example Connect to Quality Center Methods Connect Connects QuickTest to the Quality Center project. Disconnect Properties Domain Disconnects QuickTest from the Quality Center project.
The Quality Center domain to which QuickTest is currently connected. IsConnected Indicates whether QuickTest is currently connected to Quality Center. Project The Quality Center project to which QuickTest is currently connected. Server The Quality Center server to which QuickTest is currently connected. SupportVersionCont Indicates whether the Quality Center server to which rol QuickTest is connected supports version control. TDOTA Returns a TDOTA object, which exposes the Quality Center API and provides full interaction with Quality Center. User The user that is currently connected to Quality Center.
' 'This example connects to a Quality Center project, opens a test (checks it out, if applicable), 'updates the Active Screen values and test object descriptions, and, if applicable, 'checks the modified test back into the Quality Center project. ' 'Assumption s: 'The test1 test is not already checked out. 'There is no unsaved test currently open in QuickTest. 'For more information, see the example for the Test.SaveAs method. 'When QuickTest opens, it loads the add-ins required for the test. 'For more information, see the example for the Test.GetAssociatedAddins method. '************************************************************************************* *********************************** Dim qtApp 'As QuickTest.Application ' Declare the Application object variable Dim qtUpdateRunOptions 'As QuickTest.UpdateRunOptions ' Declare an Update Run
Options object variable Dim qtRunResultsOptions 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable Dim blsSupportsVerCtrl ' Declare a flag for indicating version control support Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object qtApp.Launch ' Start QuickTest qtApp.Visible = True ' Make the QuickTest application visible ' Make changes in a test on Quality Center with version control qtApp.TDConnection.Connect "http://tdserver/tdbin", _ "MY_DOMAIN", "My_Project", "James", "not4you", False ' Connect to Quality Center If qtApp.TDConnection.IsConnected Then ' If connection is successful blsSupportsVerCtrl = qtApp.TDConnection.SupportVersionControl ' Check whether the project supports vervion control qtApp.Open "[QualityCenter] Subject\tests\test1", False ' Open the test If blsSupportsVerCtrl Then ' If the project supports version control qtApp.Test.CheckOut ' Check out the test End If ' Prepare the UpdateRunOptions object Set qtUpdateRunOptions = CreateObject("QuickTest.UpdateRunOptions") ' Create the Update Run Options object ' Set the Update Run options: update the Active Screen and test object descriptions. Do not update checkpoint values qtUpdateRunOptions.UpdateActiveScreen = True qtUpdateRunOptions.UpdateCheckpoints = False qtUpdateRunOptions.UpdateTestObjectDescriptions = True ' Prepare the RunResultsOptions object Set qtRunResultsOptions = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object qtRunResultsOptions.ResultsLocation = "<TempLocation>" ' Set a temporary results location 'Update the test qtApp.Test.UpdateRun qtUpdateRunOptions, qtRunResultsOptions ' Run the test in Update Run mode qtApp.Test.Description = qtApp.Test.Description & vbNewLine & _ "Updated: " & Now ' Document the update in the test's description (Test Settings > Properties tab)
qtApp.Test.Save ' Save the test If blsSupportsVerCtrl And qtApp.Test.VerCtrlStatus = "CheckedOut" Then ' If the test is checked out qtApp.Test.CheckIn ' Check it in End If qtApp.TDConnection.Disconnect ' Disconnect from Quality Center Else MsgBox "Cannot connect to Quality Center" ' If connection is not successful, display an error message. End If qtApp.Quit ' Exit QuickTest Set qtUpdateRunOptions = Nothing ' Release the Update Run Options object Set qtRunResultsOptions = Nothing ' Release the Run Results Options object Set qtApp = Nothing ' Release the Application object Running QTP script thru command line Dim qtApp 'As QuickTest.Application ' Declare the Application object variable Dim qtTest 'As QuickTest.Test ' Declare a Test object variable Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object qtApp.Launch ' Start QuickTest qtApp.Visible = True ' Make the QuickTest application visible qtApp.Open "C:\Temp\simple_test", True ' Open the test in read-only mode ' set run settings for the test Set qtTest = qtApp.Test qtTest.Run ' Run the test WScript.StdOut.Write "Status is:" & qtTest.LastRunResults.Status ' Check the results of the test run qtTest.Close ' Close the test Set qtResultsOpt = Nothing ' Release the Run Results Options object Set qtTest = Nothing ' Release the Test object Set qtApp = Nothing ' Release the Application object How to use Quality Center Open Test Architecture API Recently I’ve encountered a task: to create a script that would connect to QC and run a test set. It was expected that the execution of this script will be initiated by Outlook. The main idea was - a notification comes to my inbox and Outlook runs the script that runs a test set.
I knew that QC (and QTP also) has its Open Test Architecture API. I’ve downloaded a manual from the QC and explored a connection method, took a peace of code that runs a test set and modified it. Here is what I got: ‘===================================== ‘ ‘ VBScript Source File — Created with SAPIEN Technologies PrimalScript 4.1 ‘ ‘ NAME: ‘ ‘ AUTHOR: Vadim Nekhai ‘ DATE : 17.12.2007 ‘ ‘ COMMENT: ‘ ‘==================================== ‘Option Explicit Public Sub RunTestSet(otdc, tsFolderName, tSetName, _ HostName, runWhere) Dim Dim Dim Dim Dim Dim Dim TSetFact, tsList theTestSet tsTreeMgr tsFolder Scheduler nPath 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 Const Const Const qcHostName = “” qcDomain = “” qcProject = “” ‘Please define here the name of the project 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
P.S. Please define in this script the path to the test set and the name of the machine where the test set is supposed to run. The script needs an argument - the name of the test set.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.