-3

I am already using implicit and fluent wait, but want to use thread.sleep, so want to know the syntax of it

2 Answers2

0

Using Thread.sleep() is discouraged and there is no Performable for that in serenity.

Many testers pepper their web tests with Thread.sleep() statements, but this is the sub-optimal at best. It slows down the tests, makes them more brittle, and can hide genuine application issues. More insidiously, when our steps are artificially slowed by sleep statements, it takes longer not only to run and troubleshoot existing tests, but also to develop new ones.

https://johnfergusonsmart.com/handling-waits-and-asynchronous-pages-in-serenity-bdd/

globalworming
  • 757
  • 1
  • 5
  • 33
0

I know my reply is very late and it's a very bad practice but I am posting here just for the sake of if it can be done. Also from your question it seems like you want to make a task of it. To do this you can make a anonymous task. For example

Integer wait = 500;    
Task.where("{0} uses thread sleep",(actor)-> {
        try {
            Thread.sleep(wait);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    });

You can wrap it inside a function or assign it to a Task variable. Just if you are wandering Task class have a overloaded method named where which takes a Consumer<Actor> as second argument instead of Performable.

Also you can make a normal task class by implementing Task and use thread sleep in performAs method.

But again considering you are using serenity I doubt it will come to the point where you would have to use Thread.sleep.