QTP - 27 Working with HP’s QC 与QC交互

本文详细介绍了如何使用HP QuickTest Professional(QTP)与Quality Center(QC)进行自动化测试,包括设置路径、使用QCUtil对象、OTA架构、连接与记录、附件管理、文件下载与上传、测试位置获取等关键步骤。

27 Working with HP’s QC

Note: First make sure QTP connect to QC.

27.1 QC Path:

QC path’s root folder is “Subject”. So all QC path startwith “[QualityCenter]Subject”. Set QC path into QTP’s Toolsà Options…àFolder(Tab)

QTP use QC paths:

DataTable.Import “[QualityCenter]Subject\Input\TestCase1.xls”

DataTable.ImportSheet “[QualityCenter]Subject\Input\TestCase1.xls”, “Global”, “Global”

 

ExecuteFile “[QualityCenter]Subject\ScriptConfiguration.vbs”

 

Note: QTP cannot use relative path, but you can write a function.

 

27.2 QCUtil Object

QCUtil Object provides the following properties:

Returns the Quality Center OTA Run object (QC: Test Plan).

Returns the collection of tests (QC: Test Lab).

Returns the Quality Center OTA TSTest object (QC: Test Lab).

Boolean value indicates whether QTP is currently connected to a QC.

Returns the Quality Center OTA QCConnection objectd

Returns the Quality Center OTA Test object (QC: Test Plan).

 

Example to use QCUtil object:

'Are we connecting to QC?

IsQCConnected = Not (QCUtil.QCConnection Is Nothing)

'Is the test stored in QC

IsTestPresentInQC = Not (QCUtil.CurrentTest Is Nothing)

'Is the test running from QC

IsTestRunningFromQC = Not (QCUtil.CurrentRun Is Nothing)

 

27.3 QC Open Test Architecture (OTA)

即QCCOM, 略。最顶层是TDConnectionObject.TDConnection Object TDConnectionObject TDConnection Object TDConnection Object TDConnection Object

27.4 TDConnectionObject

If QC connected:

 

Set TDConnection = QCUtil.QCConnection

print TDConnection.Connected

 

If QC not connected:

Set qtApp = CreateObject("QuickTest.Application")

qtApp.Launch

qtApp.Visible = True

qtApp.TDConnection.Connect "http://qcserver ", _
              "MY_DOMAIN", "My_Project", "James", "not4you", False

If qtApp.TDConnection.IsConnected Then

               print "Connect to qc is successful" & qtApp.TDConnection.User & “log in”

End if

 

27.4 TheCommand and Recordset  Object

The Command and Recordset object allow us to get data from QC DB.

Note:注意DB返回数据的格式,如果是HTML格式,就得再写一个fucntion转换成plainText格式。

'Get the TD OTA object reference

Set TDConnection = QCUTil.QCConnection

 

'Get the ID of the current test in the Data base

TestID = QCutil.CurrentTest.Field ("TS_TEST_ID")

 

'Get all the design steps present in the Test and

'read the Step Description and Expected Text

Set TDCommand = TDConnection.Command

TDCommand.CommandText =  _

  "Select DS_DESCRIPTION, DS_EXPECTED From DESSTEPS where DS_TEST_ID = " & TestID

 

'Execute the query

Set TDRes = TDCommand.Execute

 

'Loop throuh all the results in the recordset

While Not TDRes.EOR

  Msgbox TDRes.FieldValue("DS_DESCRIPTION")

  Msgbox TDRes.FieldValue("DS_EXPECTED")

 

  TDRes.Next

Wend

 

27.5  The AttachmentFactory Collection

AttachmentFactory collection can access attachments present in thefollowing object:

Requirement Tab;

Test Plan Tab: Folder, Test, Design steps;

Test Lab Tab: Folder, Test, TestSet, TestRun, TestStep

Defect;

 

Here is the example to get attachment:

  Set oAttachments = FromPlace.Attachments

'Get a collection of all attachments present

  Set allAttachment = oAttachments.NewList("")

For Each oAttachment In allAttachment

‘process each attachments

Next

 

Download attachment as the “process each attachments” (above)

Set FSO = CreateObject("Scripting.FileSystemObject")

oAttachment.Load True,""

'Copy the file from temporary downloaded location to the TOPlace folder

    FSO.CopyFile oAttachment.FileName, _

                 TOPlace & oAttachment.Name(1),True

 

27.6  Simple way to download files from QC:PathFinder & Locate method

Note: 1PathFinder based on the folders specified in the Folder Tab (ToolsàOptionàFolders)

             2 The method only used on foldersor tests present in the test plan tab

             3 If QTP local temporary fileshave same name file, will not download. So clear                              temporary files beforedownload.

sFilePath = PathFinder.Local(“QCcommon.vbs”)

‘Or full path

sFilePath = PathFinder.Local(“[QualityCenter] Subject\AllTest\QCcommon.vbs”)

 

27.7  Uploading attachment to QC

  'Get attachments (AttachmentFactory)

   Set oAttachments = QCUtil.CurrentTest.Attachments

  'Now just upload the new one

  Set oNewAttachment = oAttachments.AddItem(Null)

  oNewAttachment.FileName = NewFileName

  oNewAttachment.Type = 1 'TDATT_FILE

  oNewAttachment.Post

 

27.8  Getting the Current Test location

'Function to get the current test path is running from

Public Function GetCurrentTestPath()

  GetCurrentTestPath = ""

 

  'The test in not in QC

  If QCUtil.CurrentTest is Nothing Then Exit Function

 

  'Get the test name

  testName = CurrentTest.Name

 

  'Get the ID of the parent folder

  parentFolderID = CurrentTest.Field("TS_SUBJECT").NodeID

 

  'Get the complete path of parent folder

  parentFolderPath = QCUtil.QCConnection.TreeManager.NodePath(parentFolderID)

 

  GetCurrentTestPath = parentFolderPath & "\" & testName

End Function

 

27.9 Gettingthe Current Test Set Location:

    'Path for the folder where the Test Set exists

    testSetFolder = QCUtil.CurrentTestSet.TestSetFolder.Path

 

27.10Enumerating all the tests in test lab tab

 The Test Lab folderstructure is managed by TestSetTreeManager object. TestSet object are managedby TestSetFactory object, Each TestSet object contains test managed byTSTestFactory object.

--TestSetFactory –TestSet –ConditionFactory –Condition

                                                --TSTestFactory--TSTest--RunFactory

--TestSetTreeManager--TestSetFolder—TestSetFactory

Here is the sample code:

'This function can be used to enumerate all the test present inside a testSet.

Set allTests = oTestSet.TSTestFactory.NewList("")

  For each oTest in allTests

    Print "Test - " & oTest.name

  Next

 

Function EnumerateAllTestSets(ByVal FolderPath)

  'Check if the folder object has been passed or a string path

  If isObject(FolderPath) Then

    Set oTestSetFolder = FolderPath

  ElseIf FolderPath = "" or LCase(FolderPath) = "root" then

    'Root folder needs special handling

    Set oTestSetFolder = QCUtil.QCConnection.TestSetTreeManager.Root

  Else

    'Get the object from the path

    Set oTestSetFolder = QCUtil.QCConnection.TestSetTreeManager.NodeByPath(FolderPath)

  End If

 

  'A root folder cannot have any test set. So we need not check

  'for any testsets in case of the Root Folder.

  If oTestSetFolder.name <> "Root" Then

    Print oTestSetFolder.Path

 

    'Loop through all the test sets present in the folder

    Set allTestSets = oTestSetFolder.TestSetFactory.NewList("")

    For each oTestSet in allTEstSets

      Print "Test Set - " & oTestSetFolder.Path & "\" & oTestSet.Name

 

      'Call another function to enumerate all the test inside the current test set

      EnuemrateTestInTestSet oTestSet

    Next

  End If

 

27.11Enumerating all the tests in test plan tab

QC OTA model’s TreeManager object manage the folderstructure of test plan tab. Each folder contains folders/tests. Tests aremanaged by a TestFactory object.

--TestFactory--Test--DesignStepFactory--DesignStep

--TreeManager--SysTreeNode

Here is the sample code:

Public Function EnumerateAllTestsinTestPlan(ByVal folderPathOrObject)

  If IsObject(folderPathOrObject) Then

    'We already have a reference to the folder object

    Set oTestPlanFolder = folderPathOrObject

  ElseIf folderPathOrObject = "" or lcase(folderPathOrObject) = "subject" Then

    'Get the root subject folder

    Set oTestPlanFolder = QCutil.QCConnection.TreeManager.NodeByPath("Subject")

  Else

   'Get the folder using the string path

    Set oTestPlanFolder = QCUTil.QCConnection.TreeManager.NodeByPath(folderPathOrObject)

  End If

‘And then use NewList on that object to get the collection of tests present in the folder

Set oTestFactory = oTestPlanFolder.TestFactory.NewList("")

  For each oTest in oTestFactory

        MsgBox oTestPlanFolder.Path & "\" & oTest.Name

  Next

 

  'Recursively call this function for each sub folder

  Set allSubFolders = oTestPlanFolder.NewList()

  For each oFolder in allSubFolders

    EnumerateAllTestsinTestPlan oFolder

  Next

End Function

 

【源码免费下载链接】:https://renmaiwang.cn/s/2gdnj 《R语言数据挖掘方法及应用》由薛薇编写而成的一本系统阐述R语言在数据挖掘领域前沿技术的著作。该书旨在指导读者学会使用R语言进行高效、实用的数据分析建模工作,涵盖了从理论基础到实践操作的全过程。作为一款功能强大且开源的统计计算和图形处理平台,R语言凭借其丰富的工具库和社区支持,在数据分析可视化方面展现出显著优势。在数据挖掘领域,R语言提供了包括`caret`、`randomForest`、`tm`、`e1071`等广泛使用的专用包,这些工具能够帮助用户更便捷地进行数据预处理、特征选择、模型构建和结果评估。全书首先介绍R语言的基本知识体系,涵盖环境配置安装方法、基础语法规范以及常见数据类型分析等内容。这些基础知识是开展后续数据分析工作的必备技能,通过学习可以快速掌握R语言的核心功能。随后章节深入讲解了数据挖掘的主要概念流程,包括数据清洗、转换整理和探索性分析等环节,同时详细阐述了分类、聚类、关联规则挖掘及预测等多种典型任务的具体实施方法。这些内容有助于读者全面理解数据挖掘的整体架构及其核心工作步骤。在应用实践部分,薛薇老师结合真实案例展示了R语言在实际业务场景中的具体运用,例如市场细分分析、客户流失预测以及个性化推荐系统等。通过这些案例研究,读者可以深入学习如何利用相关工具包解决实际问题,并提升数据分析能力。此外,书中配套的“案例数据集”和“代码资源”为读者提供了实践操作的机会,使理论知识能够更好地转化为动手技能。通过实际操作分析,读者可以加深对R语言数据挖掘方法的理解并灵活运用。总之,《R语言数据挖掘方法及应用》是一部全面讲解R语言在数据分析建模领域的教材,无论你是刚开始学习的新人还是经验丰富的专业人士,都能从中获益匪浅。通过深入研读此书,你可以掌握R语言的数据挖掘技巧,并将其应用到实
内容概要:本文提出了一种基于改进粒子滤波算法的无人机三维航迹预测方法,并通过Matlab代码实现仿真验证。该方法针对传统粒子滤波在无人机轨迹预测中存在的粒子退化和计算复杂度高等问题,引入优化策略提升滤波精度效率,有效提高了对无人机运动轨迹的非线性、非高斯环境下的预测能力。文中详细阐述了算法原理、模型构建流程及关键步骤,包括状态转移建模、观测方程设计、重采样优化等,并结合三维空间中的实际飞行轨迹进行仿真实验,验证了所提方法相较于标准粒子滤波在位置预测误差和收敛速度方面的优越性。; 适合人群:具备一定信号处理、导航估计算法基础,熟悉Matlab编程,从事无人系统、智能交通、航空航天等相关领域研究的研究生或科研人员; 使用场景及目标:①应用于无人机实时轨迹预测状态估计系统中,提升飞行安全性自主性;②为复杂环境下非线性动态系统的建模滤波算法研究提供技术参考;③【预测】改进粒子滤波的无人机三维航迹预测方法(Matlab代码实现)支持后续扩展至多无人机协同跟踪避障系统的设计仿真; 阅读建议:建议结合Matlab代码逐模块分析算法实现细节,重点关注粒子滤波的改进机制三维可视化结果对比,同时可尝试替换不同运动模型或噪声条件以深入理解算法鲁棒性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值