public class WebUser<T extends WebUser<?>> extends Object
openBrowser()
: creates an instance of WebDriver, thus opening a real browserdoTask(WebTask)
: performs the given actions against the SUTA typical use is as follows:
new WebUser()
.openBrowser()
.doTasks(
new XYTask(),
new YZTask(),
[..]
).closeBrowser()
;
BTW, this is how tests will look like.
Typically the navigation will be performed by tasks.
Using browseTo(String)
instead is not recommended,
and it will probably be deprecated/removed.
A WebUser may have a username and a password.
WebUser may be extended in case more information were required (e.g.: a role).
Subclasses should just add fields, setters, and getters,
and possibly override equals(WebUser)
.
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
logger |
Constructor and Description |
---|
WebUser()
Create a WebUser with a closed
Browser , and no initial page. |
WebUser(Browser browser)
Create a WebUser with the given Browser (which may be open or closed)
and no initial page.
|
WebUser(Browser browser,
WebPage initialPage)
Create a WebUser with the given Browser (which may be open or closed)
and the given initial page.
|
Modifier and Type | Method and Description |
---|---|
T |
browseTo(String relativeUrl) |
void |
closeBrowser()
Any method chain ends with this method.
|
T |
doTask(WebTask task)
Run the given task (or tasks,
if it is a
CompositeWebTask ),
starting from the known current page
(which is part of the state of this object). |
T |
doTasks(WebTask... tasks)
Instantiate a
CompositeWebTask made up of all
of the given tasks, and run it. |
boolean |
equals(Object o) |
boolean |
equals(WebUser<?> user) |
Browser |
getBrowser() |
WebPage |
getCurrentPage() |
String |
getPassword() |
String |
getUsername() |
T |
openBrowser()
Open the browser previously specified with
withBrowserType(SupportedBrowser) . |
T |
openBrowser(SupportedBrowser browserType)
Open the browser but do not navigate to any page yet.
|
T |
withBrowserType(SupportedBrowser browserType) |
T |
withPassword(String password) |
T |
withUsername(String username) |
public WebUser()
Browser
, and no initial page.public WebUser(Browser browser)
browser
- public T openBrowser(SupportedBrowser browserType)
Browser.open(SupportedBrowser)
public T openBrowser()
withBrowserType(SupportedBrowser)
.IllegalStateException
- if the browser type has not been specified,
i.e. withBrowserType has not been calledopenBrowser(SupportedBrowser)
public void closeBrowser()
Browser.close()
public T browseTo(String relativeUrl)
relativeUrl
- a relative URL (relative to WebPage.BASE_URL
)Browser.browseTo(String)
public T doTask(WebTask task)
CompositeWebTask
),
starting from the known current page
(which is part of the state of this object).
Finally update the current page with the one
the given task visited last.task
- WebTask.run(WebPage)
public T doTasks(WebTask... tasks)
CompositeWebTask
made up of all
of the given tasks, and run it.
Convenience method for running multiple tasks at once
without wrapping them around a CompositeWebTask
by hand.
tasks
- doTask(WebTask)
public WebPage getCurrentPage()
public String getUsername()
public String getPassword()
public T withBrowserType(SupportedBrowser browserType)
public Browser getBrowser()
public boolean equals(WebUser<?> user)
user
- Copyright © 2015. All rights reserved.