![](/img/trans.png)
[英]Variable '${username1}' not found Variable using Robot Framework with DataDriver library
[英]Variable '${username}' not found while using Robot Framework with DataDriver library
我是 Robot Framework 的新手,現在在我的機器人腳本中使用 DataDriver 庫時卡住了。
我的問題:有一條消息:“未找到變量‘${username}’。” 當我運行機器人腳本時,測試失敗了。
這是我的機器人腳本:
*** Settings ***
Library DataDriver file=resources/user_password.csv encoding=utf_8 dialect=unix
Test Template Test Credential
*** Test Cases ***
Doing Test Credentials for ${username} and ${password}
*** Keywords ***
Test Credential
[Arguments] ${username} ${password}
Log ${username}
Log ${password}
這是我的 CSV 文件:
*** Test Cases ***, ${username}, ${password}, [Tags], [Documentation]
Valid user, user@mail.com, pass123, Positive, This is valid user credential
Invalid user, invalid@mail.com, pass123, Negative, This user is invalid
Invalid password, user@mail.com, pass, Negative, This password is invalid
Blank user, ${EMPTY}, pass123, Negative, Blank user
Blank password, user@mail.com, ${EMPTY}, Negative, Blank password
Blank user and password, ${EMPTY}, ${EMPTY}, Negative, Blank both user and password
任何幫助將不勝感激。 謝謝。
威利
我認為問題在於:
*** Test Cases ***
Doing Test Credentials for ${username} and ${password}
您沒有將任何變量傳遞給關鍵字,如 DataDriver 庫的文檔中所示: https : //github.com/Snooz82/robotframework-datadriver#example-test-suite
一個解決方案是將一些值傳遞給關鍵字:
*** Test Cases ***
Doing Test Credentials for ${username} and ${password} secret-user secret-pwd
編輯:
另一個是 csv 文件的格式。 如果我刪除它們,則在每個逗號后包含空格:
*** Test Cases ***,${username},${password},[Tags],[Documentation]
Valid user,user@mail.com,pass123,Positive,This is valid user credential
我可以毫無問題地運行它:
和報告:
我還觀察到,如果我們不在“Library DataDriver file=resources/logindata2.csv endocing=uft_8”中給出“dialect=unix” ,則會出現錯誤
未找到變量“${username}”。 或未找到變量“${password}”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.