【问题标题】:Robot Framework : UnboundLocalError: local variable 'cellValue' referenced before assignment机器人框架:UnboundLocalError:分配前引用的局部变量“cellValue”
【发布时间】:2018-11-14 13:42:41
【问题描述】:

下面是我的代码,

*** 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 行,但找不到确切原因。

【问题讨论】:

标签: python testing robotframework


【解决方案1】:

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

【讨论】:

  • 您能否详细说明您的示例。您是否能够重现该问题,然后使用您的建议解决它?
猜你喜欢
  • 2017-08-10
  • 2020-01-16
  • 2019-12-05
  • 2017-09-19
  • 2020-09-26
  • 2022-01-02
  • 2019-03-22
  • 2019-01-24
  • 2021-07-01
相关资源
最近更新 更多