Robot Framework:UnboundLocalError:在赋值

时间:2018-06-05 06:53:34

标签: python testing robotframework

以下是我的代码,

*** Settings ***
Documentation    This test case is to verify the registration
Library    Selenium2Library
Library    ExcelLibrary        

*** Variables ***
${SERVER}                    URL
${BROWSER}                   Firefox
${DELAY}                     10
${DELAY1}                    20
${CreateAccountLink}         //footer[@class='Panel__Footer-kGqwaT kqVeay']//div//a[@href='/signup']
${UsernameTextBox}           //input[@autocomplete='username']
${Password}                  test123
${PasswordTextBox}           //input[@minlength='6']
${SignUpButton}              //button[@type='submit']
${HeaderAccountNameBtn}     //button[@class='Header__AccountButton-leDArq bDGoru']



*** Keywords ***`enter code here`
Registration    

    Click Link                       ${CreateAccountLink}
    Page Should Contain Button       ${SignUpButton}
    Open Excel Current Directory     robottestdata.xls
    ${userName}                      Read Cell Data By Name    Sheet1    username     
    Clear Element Text               ${UsernameTextBox}
    Input Text                       ${UsernameTextBox}    ${userName}
    Clear Element Text               ${PasswordTextBox}
    Input Password                   ${PasswordTextBox}    ${Password}
    Click Button                     ${SignUpButton}      
    Set Selenium Implicit Wait       ${DELAY}
    Page Should Contain Button       ${HeaderAccountNameBtn}   
    Capture Page Screenshot          filename=-screenshot-registration.png

在运行测试时我收到了错误,

  

UnboundLocalError:之前引用的局部变量'cellValue'   分配

我发现错误发生在第4行,但找不到确切的原因。

1 个答案:

答案 0 :(得分:0)

要解决此错误,请在" Variables"中初始化变量$ {userName}。部分。