【问题标题】:Robot Framework- TypeError: object of type 'NoneType' has no len()Robot Framework-TypeError:“NoneType”类型的对象没有 len()
【发布时间】:2018-08-14 03:48:54
【问题描述】:

我是机器人框架的新手(使用 Ride),我创建了一个项目,在该项目中我使用用户关键字生成随机值,即

*** Keywords ***
Random Value
    [Arguments]    ${x_boundry}    ${y_boundry}
    Evaluate    random.randint(${x_boundry},${y_boundry})    random

现在我将随机值存储在标量变量中,即

${ran}    Random Value    1    5

并在任何输入字段中使用它(对输入数值没有限制)即

Input Text    //input[@id='firstname']    ${ran}

但是运行后出现程序错误-

TypeError: object of type 'NoneType' has no len().

在骑行机器人框架中使用它。如果需要任何其他信息,请告诉我。

【问题讨论】:

  • Input Text //input[@id='firstname'] ${ran} - 它应该做什么?
  • @Psytho- 在自动化中,它用于在字段中输入一些文本。例如 - 在电子邮件字段中,您必须输入一个电子邮件地址,然后使用此关键字。
  • 定位器 (//input[@id='firstname']) 的格式是否正确?
  • 是的,完全正确

标签: python selenium automation robotframework


【解决方案1】:

您不会从Random Value 返回任何东西。这就是为什么${ran} 仍然是None。你必须从Random Value返回一个值:

Random Value
    [Arguments]    ${x_boundry}    ${y_boundry}
    ${output}    Evaluate    random.randint(${x_boundry},${y_boundry})    random
    [Return]    ${output}

【讨论】:

    猜你喜欢
    • 2021-03-03
    • 2015-07-30
    • 1970-01-01
    • 2016-06-06
    • 1970-01-01
    • 2018-06-11
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多