将测试用例结果添加到 Quality Center 从外部 Python 脚本运行

发布于 2024-12-10 03:42:59 字数 1823 浏览 2 评论 0原文

我想尝试添加所有步骤详细信息 - 预期、实际、状态、 等到Python脚本中测试集测试用例的QC运行 住在质量中心外面。 我已经来到这里(下面给出的代码),但我不知道如何添加 步骤预期和步骤实际结果。如果有人知道怎么做的话 请帮帮我!拜托,我不需要任何 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

希望这对你们有帮助。如果您知道设置的答案 实际结果,请帮助我并让我知道。谢谢, 阿米特

I want to try to add all the step details - Expected, Actual, Status,
etc. to a QC Run for a testcase of a TestSet from a Python Script
living outside the Quality Center.
I have come till here (code given below) and I don't know how to add
Step Expected and Step Actual Result. If anyone knows how do it,
please help me out!! Please, I don't want any QTP solutions.
Thanks,
Code-

# 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

Hope this helps you guys out there. If you know the answer to set the
Actual Result, please help me out and let me know. Thanks,
Amit

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

停滞 2024-12-17 03:42:59

正如 Ethan Furman 在上一个问题中回答的 :

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

换句话说,您可能想要执行 step1.Field['ST_ACTUAL'] = 'My实际结果'

As Ethan Furman answered in your previous question:

In Python () represent calls to functions, while [] represent indexing and mapping.

So in other words, you probably want to do step1.Field['ST_ACTUAL'] = 'My actual result'

少跟Wǒ拽 2024-12-17 03:42:59

经过大量谷歌搜索后找到了答案:)

简单 ->只要这样做:

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.

谢谢大家...

Found the answer after a lot of Google Search :)

Simple -> Just do this:

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

If the above code fails to work, try to do the following:-

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

Thank you all...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文