Class OnStage
java.lang.Object
net.serenitybdd.screenplay.actors.OnStage
public class OnStage
extends java.lang.Object
The stage is used to keep track of the actors taking part in a Screenplay test.
It is useful if you don't keep track of the actors explicitly, but just refer to them by name, as is often done
in Cucumber scenarios.
Actors can be referred to by name (which must be unique for a given actor) or a pronoun.
The default pronouns are "he","she","they" and "it", and they are used interchangeably - any pronoun will always
refer to last named actor who performed some action.
Pronouns can be configured using the screenplay.pronouns property, e.g.
screenplay.pronouns = il,elle
The current stage is kept as a ThreadLocal object, so if you have multiple threads in the same Screenplay test,
you need to propagate the stage to each new thread using the setTheStage() method.-
Constructor Summary
Constructors Constructor Description OnStage()
-
Method Summary
Modifier and Type Method Description static Actor
aNewActor()
Create a new actor whose name is not yet known.static void
drawTheCurtain()
Perform any cleanup actions on each actor on the stage.static Stage
setTheStage(Cast cast)
Set the stage before calling the actorsstatic Stage
setTheStage(Stage stage)
Set the stage to a specific stage object.static Stage
stage()
Get the current stage.static Actor
theActor(java.lang.String actorName)
A shorter version of "theActorCalled()"static Actor
theActorCalled(java.lang.String requiredActor)
Returns an actor with a given name, creating a new actor if the actor is not already on stage.static Actor
theActorInTheSpotlight()
The actor in the spotlight is the last actor on the stage who has performed any activity.static void
withCurrentActor(Performable... performTasks)
A shorter version of "theActorInTheSpotlight().attemptsTo(...)"Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
OnStage
public OnStage()
-
-
Method Details
-
setTheStage
Set the stage before calling the actors -
setTheStage
Set the stage to a specific stage object. This is rarely needed but sometimes comes in handy when running tasks in parallel. -
theActorCalled
Returns an actor with a given name, creating a new actor if the actor is not already on stage. If a pronoun is used (e.g "she creates a new account") then the current actor in the spotlight will be used. -
aNewActor
Create a new actor whose name is not yet known. The next time the theActorCalled() method is used, this name will be assigned to this actor. -
theActor
A shorter version of "theActorCalled()" -
theActorInTheSpotlight
The actor in the spotlight is the last actor on the stage who has performed any activity. -
withCurrentActor
A shorter version of "theActorInTheSpotlight().attemptsTo(...)" -
stage
Get the current stage. Rarely needed for non-internal use, except when running tasks in parallel. In that case, you will need to call OnStage.setTheStage(stage) in each parallel thread if you use OnStage methods such as theActorInTheSpotlight() -
drawTheCurtain
public static void drawTheCurtain()Perform any cleanup actions on each actor on the stage. This calls the `wrapUp()` method if defined on each actor on the stage.
-