30
TDConnection Object Description An object that enables you to manage the Quality Center connection and retrieve the TDOTA object, which provides full interaction with Quality Center. Examples Connect to Quality Center Methods Connect Connects QuickTest to the Quality Center project. Disconnect Disconnects QuickTest from the Quality Center project. Properties Domain 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.

TD Connections

Embed Size (px)

Citation preview

Page 1: TD Connections

TDConnection Object

Description

An object that enables you to manage the Quality Center connection and retrieve the TDOTA object, which provides full interaction with Quality Center.

Examples

Connect to Quality Center

Methods Connect Connects QuickTest to the Quality Center project. 

 Disconnect Disconnects QuickTest from the Quality Center project. 

Properties Domain 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. 

 SupportVersionControl Indicates whether the Quality Center server to which QuickTest is connected supports version control. 

 TDOTA Returns a TDOTA object, which exposes the Quality Center API and provides full interaction with Quality Center. 

Page 2: TD Connections

 User The user that is currently connected to Quality Center. 

Connect Method

Description

Connects QuickTest to the Quality Center project.

Syntax

object.Connect ServerURL, DomainName, ProjectName, UserName, Password, EncryptedPW

Argument Description

object An expression evaluating to an object of type TDConnection.

ServerURL Required. A String value. The URL address of the Web server where your Quality Center project is installed.  The URL can specify a Web server accessible via a Local Area Network (LAN) or a Wide Area Network (WAN). 

DomainName Required. A String value. The domain that contains the Quality Center project. 

ProjectName Required. A String value. The Quality Center project to which you want to connect. 

Page 3: TD Connections

UserName Required. A String value. The user name for opening the specified project.

Password Required. A String value. The password for the specified user.  You can enter the password in encrypted or unencrypted format.  Confirm that the EncryptedPW property value matches the type of value you set here. 

To find the encrypted value of the password, use the Password Encoder utility (Start > Programs > QuickTest Professional > Tools > Password Encoder). For more information, refer to the QuickTest Professional User's Guide.

EncryptedPW Required. A Boolean value. Indicates whether the Password property is entered in encrypted or unencrypted format.Possible values: 

True--The specified password is encrypted. 

False--The specified password is not encrypted.  

Return ValueNone 

Disconnect Method

Description

Disconnects QuickTest from the Quality Center project.

Page 4: TD Connections

Syntax

object.Disconnect

Argument Description

object An expression evaluating to an object of type TDConnection.

Return ValueNone  

Examples

Disconnect from Quality Center

Domain Property

Description

The Quality Center domain to which QuickTest is currently connected.

Syntax

object.Domain

Argument Description

Page 5: TD Connections

object An expression evaluating to an object of type TDConnection.

Value TypeRead-only. A String value.

Project Property

Description

The Quality Center project to which QuickTest is currently connected.

Syntax

object.Project

Argument Description

object An expression evaluating to an object of type TDConnection.

Value TypeRead-only. A String value.

Server Property

Page 6: TD Connections

Description

The Quality Center server to which QuickTest is currently connected.

Syntax

object.Server

Argument Description

object An expression evaluating to an object of type TDConnection.

Value TypeRead-only. A String value.

SupportVersionControl Property

Description

Indicates whether the Quality Center server to which QuickTest is connected supports version control.

Syntax

object.SupportVersionControl

Argument Description

object An expression evaluating to an object of type TDConnection.

Page 7: TD Connections

Value TypeRead-only. A Boolean value. 

Possible Values True--The current Quality Center project supports version control.  False--The current Quality Center project does not support version control.

Examples

Check if the Quality Center Project Supports Version Control

TDOTA Property

Description

Returns a TDOTA object, which exposes the Quality Center API and provides full interaction with Quality Center.

Syntax

object.TDOTA

Argument Description

object An expression evaluating to an object of type TDConnection.

Page 8: TD Connections

Value TypeRead-only. A TDOTA object.

TDOTA Object

Description

Using the Quality Center Open Test Architecture (previously TDOTA), you can integrate your own requirement and configuration management tools, defect tracking tools, third-party and custom tools, and modeling applications.

You can:

Remotely execute tests in your testing application on multiple hosts across a network and analyze the test results from within the Quality Center environment.

Use the Quality Center COM-based API to enable your application to create, retrieve, and update Quality Center project records from within your test application environment.

For more information, refer to the Mercury Quality Center Open Test Architecture API Reference, which is supplied with your Quality Center package.

User Property

Page 9: TD Connections

Description

The user that is currently connected to Quality Center.

Syntax

object.User

Argument Description

object An expression evaluating to an object of type TDConnection.

Value TypeRead-only. A String value.

RunResultsOptions Object

Description

A collection of properties that indicate preferences for the run results.

Remarks

After setting the property values for a RunResultsOptions object, you can use the object as an argument in a Test.Run or Test.UpdateRun statement.

Examples

Configure Options for Test Run Results

Page 10: TD Connections

Properties ResultsLocation The path in which the run results will be stored. 

 TDRunName The Quality Center test run name. 

 TDTestInstance The Quality Center test instance. 

 TDTestSet The Quality Center test set name. 

ResultsLocation Property

Description

The path in which the run results will be stored.

Syntax

object.ResultsLocation [= value]

Argument Description

object An expression evaluating to an object of type RunResultsOptions.

value A String value. 

Value TypeRead-write. A String value. 

Page 11: TD Connections

Possible Values

A specific file system folder path in which you want to save the results for the current test or component.  

<NewLocation>--saves the run results to a new, default folder.  

When working with a test in the file system or when running a component from QuickTest, the test results are saved in <QuickTest installation folder>\Tests\<TestName\<ResX>, where ResX is a unique folder name under the test folder.  

When working with a test in Quality Center, the results are saved using the values from the TDRunName, TDTestInstance, and TDTestSet properties.

This option corresponds to the top radio button in the Run dialog box.

<TempLocation>--saves the run results in the <System Drive>\Temp\TempResults temporary results folder. This overwrites any results previously saved in this folder. 

This option corresponds to the bottom radio button in the Run dialog box.

Remarks

If no value is specified for the the ResultsLocation property, or the property value is an empty string, then the results are saved using the same settings as the previous test run.

The folder must be new, empty, or contain only QuickTest test or component files. 

Examples

Specify Location for a Test Results File

Page 12: TD Connections

TDRunName Property

Description

The Quality Center test run name.

Syntax

object.TDRunName [= value]

Argument Description

object An expression evaluating to an object of type RunResultsOptions.

value A String value. 

Value TypeRead-write. A String value.

TDTestInstance Property

Description

The Quality Center test instance.

Syntax

object.TDTestInstance [= value]

Page 13: TD Connections

Argument Description

object An expression evaluating to an object of type RunResultsOptions.

value A Long value. 

Value TypeRead-write. A Long value.

TDTestSet Property

Description

The Quality Center test set name.

Syntax

object.TDTestSet [= value]

Argument Description

object An expression evaluating to an object of type RunResultsOptions.

value A String value. 

Value TypeRead-write. A String value.

Page 14: TD Connections

Run Method

Description

Runs the open test or business component and creates results in the specified file or Quality Center path.

Syntax

object.Run [ResultsOptions], [WaitOnReturn], [Parameters]

Argument Description

object An expression evaluating to an object of type Test.

ResultsOptions Optional. A RunResultsOptions object. If no RunResultsOptions object is specified, the default value for the RunResultsOptions object is used (the results are saved in a unique folder within the test's or component's folder). 

WaitOnReturn Optional. A Boolean value. Indicates whether the Test.Run statement waits until the end of the of the run before performing the next statement in the automation script.  Default=True. 

Note: Set this property to False only if the steps following the Test.Run statement can be performed even while the test or component is running.

Page 15: TD Connections

Parameters Optional. A Parameters object. The Parameters collection containing the values you want to pass to the test or component. 

Return ValueNone   

Remarks

Note: When you run a test or business component using automation, it always runs in silent mode (whether QuickTest is visible or minimized). This means that that even if QuickTest is visible, message boxes are not opened during the run session.

Examples

Run a Test for a Specified Number of Iterations  | Supply the Values of the Test Parameters for a Test Run

Parameters Collection

Description

A collection of Parameter objects.

Examples

Modify the Value of a Test Parameter in a Parameter Collection

Properties Count The number of Parameter objects in the collection. 

Page 16: TD Connections

 Item Returns the Parameter object located in the specified position. 

UpdateRun Method

Description

Runs the test or business component in update mode.

Syntax

object.UpdateRun [UpdateOptions], [ResultsOptions], [WaitOnReturn], [Parameters]

Argument Description

object An expression evaluating to an object of type Test.

UpdateOptions Optional. An UpdateRunOptions object. If no UpdateRunOptions object is specified, then the default property values are used (checkpoints, Active Screen, and test object descriptions are all updated). 

ResultsOptions Optional. A RunResultsOptions object. If no RunResultsOptions object is specified, the default value for the RunResultsOptions object is used (the results are saved in a unique folder within the test or component's folder).

WaitOnReturn Optional. A Boolean value. Indicates whether the Test.UpdateRun statement waits until the end of the of the run 

Page 17: TD Connections

before performing the next statement in the automation script.  Default=True. 

Note: Set this property to False only if the steps following the Test.UpdateRun statement can be performed even while the test or component is running.

Parameters Optional. A Parameters object. The Parameters collection containing the values you want to pass to the test or component for the update run.

Return ValueNone

Connect to Quality Center

'*****************************************************************************************************************

*******

'Description:

'

'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.

'

'Assumptions:

'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.

Page 18: TD Connections

'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

Page 19: TD Connections

    ' 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

Page 20: TD Connections

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

Specify Location for a Test Results File

'*****************************************************************************************************************

*******

'Description:

'

'This example opens a test, configures run options and settings,

'runs the test, and then checks the results of the test run.

'

'Assumptions:

'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.

'*****************************************************************************************************************

Page 21: TD Connections

*******

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

Dim qtTest 'As QuickTest.Test ' Declare a Test object variable

Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Start QuickTest

qtApp.Visible = True ' Make the QuickTest application visible

' Set QuickTest run options

qtApp.Options.Run.ImageCaptureForTestResults = "OnError"

qtApp.Options.Run.RunMode = "Fast"

qtApp.Options.Run.ViewResults = False

qtApp.Open "C:\Tests\Test1", True ' Open the test in read-only mode

' set run settings for the test

Set qtTest = qtApp.Test

qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4

qtTest.Settings.Run.StartIteration = 2

qtTest.Settings.Run.EndIteration = 4

qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs

Page 22: TD Connections

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object

qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" ' Set the results location

qtTest.Run qtResultsOpt ' Run the test

MsgBox 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

Run a Test for a Specified Number of Iterations

'************************************************************************************************************************'Description:

'

'This example opens a test, configures run options and settings,'runs the test, and then checks the results of the test run.

'

'Assumptions:'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.'************************************************************************************************************************

Page 23: TD Connections

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

Dim qtTest 'As QuickTest.Test ' Declare a Test object variable

Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Start QuickTest

qtApp.Visible = True ' Make the QuickTest application visible

' Set QuickTest run options

qtApp.Options.Run.ImageCaptureForTestResults = "OnError"

qtApp.Options.Run.RunMode = "Fast"

qtApp.Options.Run.ViewResults = False

qtApp.Open "C:\Tests\Test1", True ' Open the test in read-only mode

' set run settings for the test

Set qtTest = qtApp.Test

qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4

qtTest.Settings.Run.StartIteration = 2

qtTest.Settings.Run.EndIteration = 4

qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object

qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" ' Set the results location

Page 24: TD Connections

qtTest.Run qtResultsOpt ' Run the test

MsgBox 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

Supply the Values of the Test Parameters for a Test Run

'************************************************************************************************************************'Description:

'

'This example opens a test with predefined parameters,' gets a collection of parameter definitions, Loops on it and display each parameter details,' gets a collection of run-time parameters, change the value of one of them, run the test with parameters,' after the test run - display the value of one of the out parameters.

'

'Assumptions:' the test D:\Tests\Mytest contain in parameter called "InParam1" and out parameter called "OutParam1"'************************************************************************************************************************

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

Page 25: TD Connections

Dim pDefColl 'As QuickTest.ParameterDefinitions ' Declare a Parameter Definitions collection

Dim pDef ' As QuickTest.ParameterDefinition ' Declare a ParameterDefinition object

Dim rtParams 'As QuickTest.Parameters ' Declare a Parameters collection

Dim rtParam ' As QuickTest.Parameter ' Declare a Parameter object

'Dim cnt, Indx As Integer

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Start QuickTest

qtApp.Visible = True ' Make the QuickTest application visible

qtApp.Open "D:\Tests\MyTest"

' Retrieve the parameters collection defined for the test.

Set pDefColl = qtApp.Test.ParameterDefinitions

cnt = pDefColl.Count

Indx = 1

' Display the names and values of each of the parameters in the collection.

While Indx <= cnt

    Set pDef = pDefColl.Item(Indx)

    MsgBox "Param name: " & pDef.Name & "; Type: " & pDef.Type & "; InOut: " & pDef.InOut & "; Description: " _

        & pDef.Description & "Default value: " & pDef.DefaultValue

    Indx = Indx + 1

Wend

Page 26: TD Connections

Set rtParams = pDefColl.GetParameters() ' Retrieve the Parameters collection defined for the test.

Set rtParam = rtParams.Item("InParam1") ' Retrieve a specific parameter.

rtParam.Value = "Hello" ' Change the parameter value.

qtApp.Test.Run , True, rtParams ' Run the test with changed parameters.

MsgBox rtParams.Item("OutParam1").Value ' Display the value of an output parameter after the test runs.