|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectgeb.Browser
class Browser extends Object
The browser is the centre of Geb. It encapsulates a WebDriver implementation and references a Page object that provides access to the content.
Browser objects dynamically delegate all method calls and property read/writes that it doesn't implement to the current page instance via propertyMissing() and methodMissing().
Property Summary | |
---|---|
WebDriver |
augmentedDriver
If the driver is remote, this object allows access to its capabilities (users of Geb should not access this object, it is used internally). |
Constructor Summary | |
Browser()
Create a new browser with a default configuration loader, loading the default configuration file. |
|
Browser(Configuration config)
Create a new browser backed by the given configuration. |
|
Browser(Map props, Configuration config)
Creates a new browser instance backed by the given configuration, then applies props as property overrides on the browser. |
Method Summary | |
---|---|
boolean
|
at(Class pageType)
Checks if the browser is at the current page by running the at checker for the given page type. |
void
|
cleanReportGroupDir()
Removes the directory returned by getReportGroupDir() from the filesystem if it exists. |
void
|
clearCookies()
Clears all cookies that the browser currently has. |
void
|
clearCookiesQuietly()
Clears all cookies that the browser currently has, suppressing any webdriver exceptions. |
void
|
close()
Closes the current driver window. |
Page
|
createPage(Class pageType)
Creates a new instance of the given page type and initialises it. |
static Browser
|
drive(Closure script)
Creates a new browser object via the default constructor and executes the closure with the browser instance as the closure's delegate. |
static Browser
|
drive(Configuration conf, Closure script)
Creates a new browser with the configuration and executes the closure with the browser instance as the closure's delegate. |
static Browser
|
drive(Map browserProperties, Closure script)
Creates a new browser with the properties and executes the closure with the browser instance as the closure's delegate. |
static Browser
|
drive(Browser browser, Closure script)
Executes the closure with browser as its delegate. |
String
|
getBaseUrl()
The url to resolve all relative urls against. |
Configuration
|
getConfig()
Provides access to the configuration object assoicated with this browser. |
WebDriver
|
getDriver()
The driver implementation used to automate the actual browser. |
JavascriptInterface
|
getJs()
Returns a newly created javascript interface connected to this browser. |
Page
|
getPage()
Provides access to the current page object. |
File
|
getReportGroupDir()
The directory that will be used for the method. |
void
|
go()
Sends the browser to the configured base url. |
void
|
go(Map params)
Sends the browser to the configured base url, appending params as query parameters. |
void
|
go(String url)
Sends the browser to the given url. |
void
|
go(Map params, String url)
Sends the browser to the given url. |
def
|
methodMissing(String name, def args)
Delegates the method call directly to the current page object. |
void
|
page(Class pageClass)
Changes the browser's page to be an instance of the given class. |
void
|
page(Class[] potentialPageClasses)
Changes the browser's page to be an instance of the first given type whose at checker returns a true value. |
void
|
page(Page page)
Sets this browser's page to be the given page. |
def
|
propertyMissing(String name)
Delegates the property access directly to the current page object. |
def
|
propertyMissing(String name, def value)
Delegates the property assignment directly to the current page object. |
void
|
quit()
Quits the driver. |
void
|
registerPageChangeListener(PageChangeListener listener)
Allows new page change listeners to be registered with this browser. |
boolean
|
removePageChangeListener(PageChangeListener listener)
Removes the given page change listener. |
void
|
report(String label)
Writes a snapshot of the browser's state to the current getReportGroupDir() using the config's reporter. |
void
|
reportGroup(String path)
Sets the "group" for all subsequent reports, which is the relative path inside the reports dir that reports will be written to. |
void
|
reportGroup(Class clazz)
Sets the report group to be the full name of the class, replacing "." with "/". |
void
|
setBaseUrl(String baseUrl)
Changes the base url used for resolving relative urls. |
void
|
setDriver(WebDriver driver)
Set (or change) the webdriver underneath this browser. |
void
|
to(Class pageType, Object[] args)
Sends the browser to the given page type's url and sets the page to a new instance of the given type. |
void
|
to(Map params, Class pageType)
Sends the browser to the given page type's url and sets the page to a new instance of the given type. |
void
|
to(Map params, Class pageType, Object[] args)
Sends the browser to the given page type's url and sets the page to a new instance of the given type. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Property Detail |
---|
@Lazy WebDriver augmentedDriver
Constructor Detail |
---|
Browser()
Browser(Configuration config)
Browser(Map props, Configuration config)
Method Detail |
---|
boolean at(Class pageType)
If the give page type's at checker is successful, this browser object's page instance is updated to the given type unless it is already of the given type in which case it is not changed.
void cleanReportGroupDir()
void clearCookies()
void clearCookiesQuietly()
void close()
Page createPage(Class pageType)
static Browser drive(Closure script)
static Browser drive(Configuration conf, Closure script)
static Browser drive(Map browserProperties, Closure script)
static Browser drive(Browser browser, Closure script)
String getBaseUrl()
The base url is determined by the configuration.
Configuration getConfig()
WebDriver getDriver()
The driver implementation to use is determined by the configuration.
JavascriptInterface getJs()
Page getPage()
All browser objects are created with a page type of Page initially.
File getReportGroupDir()
Uses the Configuration.getReportsDir for the base location for reports (throwing an exception if this is not set), and appending the current report group. The returned file object is guaranteed to exist on the filesystem.
If the current report group is null, this method returns the same as config.reportsDir.
void go()
void go(Map params)
void go(String url)
void go(Map params, String url)
def methodMissing(String name, def args)
void page(Class pageClass)
This method performs the following:
Note that it does not verify that the page matches the current content by running its at checker
void page(Class[] potentialPageClasses)
This method performs the following:
void page(Page page)
Any page change listeners are informed and Page.onUnload is called on the previous page and Page.onLoad is called on the incoming page.
def propertyMissing(String name)
def propertyMissing(String name, def value)
void quit()
void registerPageChangeListener(PageChangeListener listener)
This method will immediately call the PageChangeListener.pageWillChange method on listener with the current page as the newPage argument and null for the oldPage argument.
boolean removePageChangeListener(PageChangeListener listener)
void report(String label)
label
- The name for the report file (should not include a file extension)
void reportGroup(String path)
path
- a relative path, or null to have reports written to the base reports dir
void reportGroup(Class clazz)
void setBaseUrl(String baseUrl)
This method delegates to Configuration.setBaseUrl.
void setDriver(WebDriver driver)
This should only be called before making any requests as a means to override the driver instance that would be created from the configuration. Where possible, prefer using the configuration mechanism to specify the driver implementation to use.
This method delegates to Configuration.setDriver.
void to(Class pageType, Object[] args)
void to(Map params, Class pageType)
void to(Map params, Class pageType, Object[] args)
Groovy API Documentation for geb-core 0.6.0 - Licensed under the Apache License, Version 2.0 - http://www.gebish.org