04.01 Robotframework 變量的混合運用


*** Settings ***
Variables ../Library/get_project_root_dir.py
Library Collections
Library String
*** Variables ***
#${element_account} 7 ${my_dir.root_dir()}/Images
${oppProductBigType} {'oppProductBigType':['communication', 'video', 'office', 'security', 'cloud', 'education']}
*** Test Cases ***
Test loop
Test Dict
*** Keywords ***
Test Dict
&{opp} = Evaluate ${oppProductBigType}
log ${opp}
log ${opp.oppProductBigType}[0]
log &{opp}[oppProductBigType]
${content} = Get From Dictionary ${opp} oppProductBigType
log @{content}[0]

robotframework中如果要混合使用變量使用

&{opp} = Evaluate ${oppProductBigType} 這裡使用了Evaluate函數,可以把我們使用python定義的字典和列表混合轉換為robotframework類型的變量
注意的是: 這裡接受這個變量最好用&{}而不是${}來接受,當然可以接受, 為了下面可以混合一步使用最好用&{}

${opp.oppProductBigType}[0] 更好使用些

結果如下:

Robotframework 變量的混合運用

Robotframework 變量的混合運用


分享到:


相關文章: