2017-11-07 13 views
0

xlsスプレッドシートのデータに基づいて辞書を作成しようとしています。以下は私のコードです。しかし、 "辞書に設定"(以下のコードの最後の行)を実行すると、次のエラーが表示されます。TypeError: 'unicode'オブジェクトはアイテムの割り当てをサポートしていません。私は何が欠けているかに関する任意のアイデア?辞書を作成しようとするとオブジェクトの割り当てエラーが発生する(Robot Framework)

*** Settings *** 
Library ExcelLibrary 
Library Collections 

*** Variables *** 
${PageSheetName} = Welcome Page 
${WelcomeDict} = Create Dictionary 

*** Test Cases *** 
Excel Sandbox Test 
    Get Values from Spreadsheet 
    #Print out the Dictionary 

*** Keywords *** 
Get Values from Spreadsheet 
    # Open the file 
    Open Excel Current Directory ${Excel_File_Path}DataExtract.xls 
    # Get the number of rows 
    ${iTotalRows} = Get Row Count ${PageSheetName} 
    # Loop through each row to get the data. Only need data from Columns A & B 
    : FOR ${iRowNum} IN RANGE 1 ${iTotalRows}+1 
    \ ${KeyVal} = Read Cell Data By Name ${PageSheetName} A${iRowNum} 
    \ ${Value} = Read Cell Data By Name ${PageSheetName} B${iRowNum} 
    \ Create the Welcome Page Dictionary ${KeyVal} ${Value} 

Create the Welcome Page Dictionary 
    [Arguments] ${key} ${val} 
    Set To Dictionary ${WelcomeDict} ${key} ${val} 

答えて

0

のコードブロックを考えてみましょう:

*** Variables *** 
${WelcomeDict} = Create Dictionary 

それは「辞書の作成」値で文字列変数を作成しています。 *** Variables ***セクションでキーワードを呼び出すことはできません。 robot framework user guideから

Variable tables are convenient, because they allow creating variables in the same place as the rest of the test data, and the needed syntax is very simple. Their main disadvantages are that values are always strings and they cannot be created dynamically.

あなたは、辞書を初期化&を使用し、ただの値が提供されていませんしたい場合:

*** Variables *** 
&{WelcomeDict}= 
関連する問題