Note: First make sure QTP connect to QC.(转自:http://blog.csdn.net/franktan2010/article/details/7243314)

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

QC OTA的更多相关文章

  1. ALM/QC OTA Field in Database(查询ALM数据库的字段)

    在使用ALM的OTA接口编写脚本的时候,通常会需要知道各个选项在数据库中对应的字段,才能通过脚本读取或写入数据.比如要获取test case的step内容,要在测试结束时将测试实际结果写回test s ...

  2. QC API全系列揭秘之Test Execution操作(全网首发)

    (原创文章,转载请注明出处.) 一.QC简介: Quality Center存在至今已经走过了10多个年头,名字从一开始的TD,到后来的QC,再到现在的ALM.所属公司从开始的Mercury到现在的H ...

  3. 史上最全QC学习方案,值得收藏!

    Quality Center是一个基于Web的强大的测试管理工具,可以组织和管理应用程序测试流程的所有阶段,**制定测试需求.计划测试.执行测试和跟踪缺陷.此外,通过Quality Center还可以 ...

  4. QC在win7下不能访问QC服务器介绍

    本地访问不了服务器QC的主要几个原因总结 服务器serverjbossextensionhpcmd 2016-03-24   兼容性问题: 1.在服务端QC的安装目录下jboss\server\def ...

  5. The difference between QA, QC, and Test Engineering

    Tuesday, March 06, 2007 Posted by Allen Hutchison, Engineering Manager and Jay Han, Software Enginee ...

  6. 使用HTTPS网站搭建iOS应用内测网站(OTA分发iOS应用)

    为什么要搭建应用内测网站呢? 1.AppStore的审核速度比较慢,万一被拒,还得等,而且一旦发布,任何人都可以下载,而有些时候只有老板想知道最新的修改是否符合要求,万一不符合要求呢?又要修改了. 2 ...

  7. Delphi QC 记录

    各网友提交的 QC: 官方网址 说明 备注 https://quality.embarcadero.com/browse/RSP-12985 iOS device cannot use indy id ...

  8. QC学习一:Windows环境中Quality Center 9.0安装详解

    一.安装前准备 1.安装环境:windows XP.SQL Server2005 2.准备安装文件:Quality Center 9.0 (qc10以上,包括qc10,qc只支持安装在服务器操作系统上 ...

  9. 前端Mvvm QC 上传了测试版

    QC是一个前端MVVM框架,适合用来构建复杂的业务逻辑 项目地址:https://github.com/time-go/qc 技术支持QQ群:330603020 QC特点: 1.良好的浏览器兼容性(兼 ...

随机推荐

  1. python学习第十四天字典的del(),pop().popitem(),clear()删除方法

    字典的每个键值 key=>value 数据类型,字典的key是唯一的,Value可以一样 names={'玖乐公司网址':‘www.96net.com.cn’,"电池网":' ...

  2. 关于Echarts的使用和遇到的问题

    对于插件工具,感觉按着官方的教程,便可以使用,但是看这个Echarts有点晕乎乎的,还是不能快速的学习啊. 一.在webpack中使用ECharts //通过 npm 获取 echartsnpm in ...

  3. SQL server 聚集索引与主键的区别

    主键是一个约束(constraint),他依附在一个索引上,这个索引可以是聚集索引,也可以是非聚集索引. 所以在一个(或一组)字段上有主键,只能说明他上面有个索引,但不一定就是聚集索引. 例如下面: ...

  4. github命令大全

    github是一种开源的版本控制工具,现在已经得到很多人的应用.所以想介绍一下github的一些使用. github安装 github提供了桌面客户端,我们也可以通过命令行的方式来进行控制. wind ...

  5. 转贴健康资讯:神奇的“XX水”,死了一茬又来一茬?

    神奇的“XX水”,死了一茬又来一茬? 2014年7月20日 京虎子 http://www.scipark.net/archives/19816 最近看到两桩事,一是孕妇防辐射服,一是富氧水.这两桩事合 ...

  6. [CSS布局]简单的CSS三列布局

    前言 公司终于可以上外网了,近期在搞RN的东西,暂时脑子有点晕,等过段时间再来写点总结.倒是最近有个新学前端的同学经常会问一些基础知识,工作空闲写了小Demo给他看,全是很基础的知识,纯粹是顺便记录在 ...

  7. 动态规划之数字三角形(POJ1163)

    在下面的数字三角形中寻找一条从顶部到底边的路径,使得路径上所经过的数字之和最大.路径上的每一步都只能往左下或 右下走.只需要求出这个最大和即可,不必给出具体路径. 既然求目标问题是根据查表得来的,自然 ...

  8. Linux中的bin文件夹

    ~/bin适合放个人用户的 script /usr/local/bin存放系统中所有用户都可以使用的 script /usr/local/sbin存放管理员的 script /usr/local/目录 ...

  9. Cytoscape基础教程笔记

    昨天开始学用Cytoscape,其tutorial分为两个部分,基础的和高级 的.基础教程又分成了四课:Getting Started.Filters & Editor.Fetching Ex ...

  10. Spring Security 安全认证

    Spring Boot 使用 Mybatis 依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> ...