-->

从一个Python脚本之外添加测试用例结果质量中心运行(Adding testcase result

2019-10-30 01:55发布

我想尝试所有步骤的细节加 - 预计,实际,状态等的QC运行从一个Python脚本的生活质量中心外的测试集的测试用例。 我来这里为止(如下代码),我不知道如何添加步骤预期和步骤实际结果。 如果有人知道如何做到这一点,请帮助我! 拜托,我可不想任何QTP解决方案。 谢谢,代码 -

# Script name - add_tsrun.py 
# C:\Python27\python.exe 
# This script lives locally on a Windows machine that has - Python 2.7, Win32 installed, IE8 
# Dependencies on Windows Machine - Python 2.7, PythonWin32 installed, IE8, a QC Account, connectivity to QCServer 
import win32com.client, os 
tdc = win32com.client.Dispatch("TDApiOle80.TDConnection") 
tdc.InitConnection('http://QCSERVER:8080/qcbin') 
tdc.Login('USERNAME', 'PASSWORD') 
tdc.Connect('DOMAIN_NAME', 'PROJECT') 
tsFolder = tdc.TestSetTreeManager.NodeByPath('Root\\test_me\\sub_folder') 
tsList = tsFolder.FindTestSets('testset1') 
ts_object = tsList.Item(1) 
ts_dir = os.path.dirname('testset1') 
ts_name = os.path.basename('testset1') 
tsFolder = tdc.TestSetTreeManager.NodeByPath(ts_dir) 
tsList = tsFolder.FindTestSets(ts_name) 
ts_object = tsList.Item(1) 
TSTestFact = ts_object.TSTestFactory 
TestSetTestsList = TSTestFact.NewList("") 
ts_instance = TestSetTestsList.Item(1) 
newItem = ts_instance.RunFactory.AddItem(None)   # newItem == Run Object 
newItem.Status = 'No Run' 
newItem.Name = 'Run 03' 
newItem.Post() 
newItem.CopyDesignSteps()   # Copy Design Steps 
newItem.Post() 
steps = newItem.StepFactory.NewList("") 
step1 = steps[0] 
step1.Status = "Not Completed" 
step1.post() 
## How do I change the Actual Result?? 
## I can access the Actual, Expected Result by doing this, but not change it
step1.Field('ST_ACTUAL') = 'My actual result'           # This works in VB, not python as its a Syntax error!! 
Traceback (  File "<interactive input>", line 1 
SyntaxError: can't assign to function call

希望这有助于你们在那里。 如果你知道答案设置实际结果,请帮助我,让我知道。 谢谢,阿米特

Answer 1:

至于伊森弗曼回答你前面的问题 :

在Python ()表示对函数的调用,而[]代表索引和映射。

因此,换句话说,你可能想要做step1.Field['ST_ACTUAL'] = 'My actual result'



Answer 2:

找到答案了不少谷歌搜索后:)

简单 - >只是这样做:

step1.SetField("ST_ACTUAL", "my actual result") # Wohhooooo!!!!

如果上面的代码无法工作,尽量做到以下几点: -

(OPTIONAL) Set your win32 com as follows- (Making ''Late Binding'')
# http://oreilly.com/catalog/pythonwin32/chapter/ch12.html
    a. Start PythonWin, and from the Tools menu, select the item COM Makepy utility.
    b. Using Windows Explorer, locate the client subdirectory (OTA COM Type Library)
       under the main win32com directory and double-click the file makepy.py.

谢谢你们...



文章来源: Adding testcase results to Quality Center Run from a outside Python Script