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
Sleepkeyword and the time value. For example, writeSleep 10s(notSleep10sor 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 as10s(seconds),5m(minutes), or1h(hours). Adding units makes your code more readable. - Confirm BuiltIn library access:
Sleepis 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 Listekeyword 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:
If this keyword isn't found, Robot Framework might misparse the line and throw an "empty keyword name" error.*** Settings *** Resource path/to/your/custom_keywords.resource # OR Library YourCustomKeywordLibrary - 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
相关产品推荐
相关产品推荐

