public interface WebTask
WebTask uses page objects to carry on its logic.
It is the gate between the layer 'tests' and 'pages', the one
that makes for maintainable test suites.
In fact, it allows for sharing code among tests.
Each concrete WebTask should be as fine-grained as possible:
the finer, the more reusable, the better.
Fine-grained WebTask's can be then chained together, thanks to
CompositeWebTask
.
Each WebTask in a chain is able to continue the interaction with the SUT
from the page the previous task was visiting.
Concrete WebTask's should be parametrized by fields: they should define a field for each piece of test data they need, along with a fluent setter method. Test data should be stored (statically, i.e. hardcoded, or dynamically, e.g. in a DB) in test classes and passed to WebTask's via the fluent setter methods.
It is best to think of a WebTask as a Given, When, or Then step. Please, see also BDD.
CompositeWebTask
Modifier and Type | Method and Description |
---|---|
WebUser |
getUser() |
default OrWebTask |
or(WebTask alternativeTask)
Builds an
OrWebTask made up of (in order)
this task and the given alternative task. |
WebPage |
run(WebPage initialPage)
Perform this task as the user
getUser() . |
WebTask |
setUser(WebUser user) |
WebPage run(WebPage initialPage)
getUser()
.
Precondition: the user must have already been set
(see setUser(WebUser)
).initialPage
- the page it is displayed before this task startsdefault OrWebTask or(WebTask alternativeTask)
OrWebTask
made up of (in order)
this task and the given alternative task.
This method can be "recursively" chained in order to define
a multi-member OR, e.g.:
new MyTask()
.or(new AlternativeTask1())
.or(new AlternativeTask2())
.or(new AlternativeTask3())
;
alternativeTask
- the task to run if this task failsOrWebTask
made up of (in order)
this task and the alternativeWebTask setUser(WebUser user)
user
- the user this task will run as.WebUser getUser()
Copyright © 2015. All rights reserved.