Hopeful
Hopeful

Reputation: 75

Wait laps of time between two calls to a webservice using RobotFrameWork

I want to call a webservice and recover a date1 than I want to wait couple of seconds before calling the same webservice and recover date2

I have tried with the keyWord sleep

${Date1}=   Recuperer Donnee Liste   ${monSubscriberJsonC1}    recepetionDerniereLocalisation

Log   ${Date1}

     \    Sleep 1.5

Log   ${monSubscriberJsonC2}

${Date2}=   Recuperer Donnee Liste   ${monSubscriberJsonC2}    recepetionDerniereLocalisation

Log   ${Date2}

As a message I got

Keyword name cannot be empty.

and also

No keyword with name 'Sleep 10s' found.

Upvotes: 2

Views: 1059

Answers (2)

Joonas Köppä
Joonas Köppä

Reputation: 366

Here's the Sleep keyword documentation: https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Sleep

Applied to your given example:

${Date1}=   Recuperer Donnee Liste   ${monSubscriberJsonC1}    recepetionDerniereLocalisation

Log   ${Date1}
Sleep  1.5s

Log   ${monSubscriberJsonC2}

${Date2}=   Recuperer Donnee Liste   ${monSubscriberJsonC2}    recepetionDerniereLocalisation

Log   ${Date2}

It's always good to write the unit after sleep times. As you see from the documentation it's also possible to sleep milliseconds ms which is often the default when dealing with time, unlike in Robot where the default is a second.

Upvotes: 2

asprtrmp
asprtrmp

Reputation: 1062

This No keyword with name 'Sleep 10s' found. occurs because you don't have the minimun two spaces between keyword (Sleep) and argument(s) (10s). Add a space between them.

Also, \ is used for loop indendation.

Upvotes: 3

Related Questions