Robot框架:UnboundLocalError:在assignmen之前引用了局部变量“cellValue”

2024-09-30 18:35:26 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是我的代码

*** 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: local variable 'cellValue' referenced before assignment

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


Tags: textinputlibrarypageusernamebuttonpasswordregistration