0

Quality Center の外部にある Python スクリプトから、TestSet のテストケースの QC Run にすべてのステップの詳細 (Expected、Actual、Status など) を追加したいと考えています。私はここまで来ました (以下のコード)。Step Expected と Step Actual Result を追加する方法がわかりません。やり方わかる人いたら教えてください!!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

これが皆さんのお役に立てば幸いです。実際の結果を設定するための答えを知っている場合は、私を助けて教えてください. ありがとう、アミット

4

2 に答える 2

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.

皆さん、ありがとうございました...

于 2011-10-27T22:36:25.460 に答える
2

イーサン・ファーマンが前の質問で答えたように:

Python では()、関数の呼び出しを[]表し、インデックス作成とマッピングを表します。

言い換えれば、おそらくやりたいことですstep1.Field['ST_ACTUAL'] = 'My actual result'

于 2011-10-16T16:34:42.897 に答える