簡體   English   中英

未找到變量 '${username1}' 使用帶有 DataDriver 庫的 Robot Framework 的變量

[英]Variable '${username1}' not found Variable using Robot Framework with DataDriver library

我是 Robot Framework 的新手,現在在我的機器人腳本中使用 DataDriver 庫時卡住了。

我的問題:有一條消息:“未找到變量 '${username1}'。” 當我運行機器人腳本並且測試失敗時。

我的腳本:

*** Test Cases ***
Login with user ${username} and password ${password}        xyc     123456



*** Keywords ***
Validate Unsuccessful Login
    [Arguments]     ${username1}        ${password1}
    open the browser with the Mortgage payment url
    Fill the login Form     ${username1}        ${password1}
    wait until it checks and display error message
    verify error message is correct
Fill the login Form
    [Arguments]         ${username1}        ${password1}
    input text          id:username          ${username1}
    input password      id:password          ${password1}
    select checkbox     id:terms
    click button        signInBtn

錯誤:

testDemo5 :: To validate the login form                                       
==============================================================================
Invalidusername,nina,learning                                         | FAIL |
Variable '${username1}' not found.
------------------------------------------------------------------------------
Invalidpassword,rahulshetty,nina                                      | FAIL |
Variable '${username1}' not found.
------------------------------------------------------------------------------
Specialcharacter,@#$##,uqyuyw                                         | FAIL |

任何幫助將不勝感激。 謝謝。

Variable '${username1}' not found. 可能由以下一種或多種原因引起:

  1. CSV 文件在 header 中使用逗號代替分號
  2. CSV 標頭中有空格
  3. 模板關鍵字中的 arguments 與測試用例中的嵌入變量不匹配。

看起來問題 3 肯定是您的代碼中的情況,因此您需要將Validate Unsuccessful Login更改為以下內容:

Validate Unsuccessful Login
    [Arguments]     ${username}        ${password}
    open the browser with the Mortgage payment url
    Fill the login Form     ${username}        ${password}
    wait until it checks and display error message
    verify error message is correct

然后檢查您的 csv 文件

這種風格是有效的:

*** Test Cases ***;${username};${password};[Tags];[Documentation]

這種風格會導致錯誤:

*** Test Cases ***,${username},${password},[Tags],[Documentation]

這也會導致錯誤:

*** Test Cases ***; ${username}; ${password}; [Tags]; [Documentation]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM