You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RobotFramework中两次WebService调用的等待时长问题排查

Fixing Robot Framework Errors: "Keyword name cannot be empty" and "No keyword with name 'Sleep 10s' found"

Let's break down and resolve each error you're encountering in your test script:

1. Resolving "No keyword with name 'Sleep 10s' found"

This error pops up when Robot Framework misinterprets the entire string "Sleep 10s" as a single keyword name instead of recognizing "Sleep" as the keyword and "10s" as its argument. Here's how to fix it:

  • Use proper spacing: Make sure there's a clear space between the Sleep keyword and the time value. For example, write Sleep 10s (not Sleep10s or any joined variation).
  • Validate time formats: You can pass a raw number (interpreted as seconds, like Sleep 1.5) or a string with explicit units such as 10s (seconds), 5m (minutes), or 1h (hours). Adding units makes your code more readable.
  • Confirm BuiltIn library access: Sleep is part of Robot Framework's default BuiltIn library, so you don't need to explicitly import it unless you've overridden it with a custom keyword of the same name.

2. Fixing "Keyword name cannot be empty"

This error usually stems from a malformed line in your script, most commonly a variable assignment missing a keyword. Let's address potential issues:

  • Check variable assignment syntax: The correct format is ${VariableName}= KeywordName Argument1 Argument2. Ensure there are spaces before and after the = sign, and spaces separating the keyword from its arguments.
  • Verify custom keyword availability: Your Recuperer Donnee Liste keyword is custom, so double-check that it's properly defined in a resource file or library imported at the top of your test suite. For example:
    *** Settings ***
    Resource  path/to/your/custom_keywords.resource
    # OR
    Library  YourCustomKeywordLibrary
    
    If this keyword isn't found, Robot Framework might misparse the line and throw an "empty keyword name" error.
  • Remove empty indented lines: Accidental blank lines within your test case (especially indented ones) can also trigger this error.

Corrected Code Example

Here's your script with the necessary fixes applied:

*** Settings ***
# Uncomment and adjust the line below if your custom keyword comes from a resource file
# Resource  path/to/your/keywords.resource

*** Test Cases ***
CompareWebServiceTimestamps
    ${Date1}=    Recuperer Donnee Liste    ${monSubscriberJsonC1}    recepetionDerniereLocalisation
    Log    ${Date1}
    Sleep    1.5s  # Added unit for clarity (1.5 works too)
    Log    ${monSubscriberJsonC2}
    ${Date2}=    Recuperer Donnee Liste    ${monSubscriberJsonC2}    recepetionDerniereLocalisation
    Log    ${Date2}

内容的提问来源于stack exchange,提问作者Hopeful

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:13:01