@groovy.util.logging.Slf4j class BaseGUISpecification extends BaseSpecification
This is the common Spock specification base class for GUI/GEB tests. This includes login/out and debug functions for GEB elements.
Type | Name and description |
---|---|
private java.util.Locale |
currentLocale The current local being tested. |
private static java.util.List<java.lang.String> |
dumpAttributes |
private static java.lang.String |
loggedInUser Tracks the current user logged in. |
private static java.lang.Boolean |
searchServerUp See if the search server is up. |
private static java.lang.Object |
specNeeds Makes sure the GUI test has GEB GUI, embedded server and database. |
Constructor and description |
---|
BaseGUISpecification
() |
Type Params | Return Type | Name and description |
---|---|---|
|
groovy.lang.Tuple2 |
calculateOffset(java.lang.Object element1, java.lang.Object element2) Calculates the display offsets between a given pair of GEB (HTML) elements. |
|
boolean |
checkMenuLabels(java.lang.String menuName, java.lang.String menuLabel, java.util.List<java.util.List<java.lang.String>> subMenus) Check a menu from a toolbar-style menu with some sub menus. |
|
void |
cleanup() Restores any globals that were mocked. |
|
void |
clickButton(java.lang.String id) Clicks a toolkit button with the given view ID. |
|
void |
clickMenu(java.lang.String menuID, java.lang.String subMenuID) Clicks a menu (and maybe sub menu). |
|
java.lang.String |
dumpElement(java.lang.Object elementList, int level) Creates a human readable debug representation of the given element and its children (recursive). |
|
protected java.lang.Object |
findLogoutButton() Finds the logout button on the current page. |
|
int |
getColumnIndex(java.lang.Class domainClass, java.lang.String columnName) Determines the column index for the given column (field) name for the given domain. |
|
geb.navigator.Navigator |
getComboListItem(java.lang.String id) Finds the combobox popup list item with the given ID. |
|
java.lang.String |
getFieldLabel(java.lang.String fieldName) Finds the field label (text) for the given field name. |
|
geb.navigator.Navigator |
getInputField(java.lang.String fieldName) Finds the given input text field element on the GUI. |
|
java.lang.String |
getReadonlyFieldValue(java.lang.String fieldName) Finds the field value (text) for the given field name. |
|
java.lang.String |
getTooltip(java.lang.String id) Returns the given dynamic tooltip (needed for toolkit 8.0 tooltips on buttons). |
|
boolean |
isFireFox() Returns true if the GUI test is running in firefox. |
|
static boolean |
isSearchServerUp() |
|
void |
login(java.lang.String _userName, java.lang.String passwordInput) Logs the user in as the given user, if not already logged in. |
|
void |
logout() Logs the user out. |
|
java.lang.String |
lookup(java.lang.String key, java.util.Locale locale, java.lang.Object[] args) Convenience method for general message.properties lookup. |
|
java.lang.String |
lookupRequired(java.lang.String key, java.util.Locale locale, java.lang.Object[] args) Convenience method for general message.properties lookup for fields marked as required. |
|
boolean |
nonZeroRecordCount(java.lang.Class domainClass) Returns true if the given domain has non-zero record count. |
|
void |
sendKey(java.lang.Object keys) Send the key(s) without wait to the browser. |
|
void |
setCombobox(java.lang.Object combobox, java.lang.String id) Sets a combobox to the given ID setting. |
|
void |
setCombobox(java.lang.String view, java.lang.String id) Sets a combobox to the given ID setting. |
|
void |
setFieldValue(java.lang.String fieldName, java.lang.Object expectedValue, java.lang.Object newValue) Checks and sets the given field value. |
|
void |
setMultiCombobox(java.lang.Object combobox, java.util.List values) Sets a multi-select combobox to the given list of IDs. |
|
void |
setMultiCombobox(java.lang.String view, java.util.List values) Sets a multi-select combobox to the given list of IDs. |
|
java.lang.Object |
setup() Initializes the GUI, if needed. |
|
void |
standardGUISleep(int multiplier) Convenience method to wait a standard delay time (approx 100ms) for the GUI to react. |
|
void |
waitForAjaxCompletion() Waits for the combobox in a grid to display the input value. |
|
void |
waitForGridComboboxInputValue(java.lang.String value) Waits for the combobox in a grid to display the input value. |
|
void |
waitForNonZeroRecordCount(java.lang.Class domainClass) Wait for a record to to be created in the database. |
The current local being tested. Comes from the -Dgeb.lang option (e.g. -Dgeb.lang=de-DE). (Default: en-US).
Tracks the current user logged in.
See if the search server is up.
Makes sure the GUI test has GEB GUI, embedded server and database.
Calculates the display offsets between a given pair of GEB (HTML) elements. This is the distance to move from element1 to element2.
element1
- The first GEB element.element2
- The second GEB element.Check a menu from a toolbar-style menu with some sub menus.
menuName
- The top-level menu.menuLabel
- The top-level menu lookup key.subMenus
- The list of menus to check (element 0 = menu ID, element 1 = lookup key for label.Restores any globals that were mocked.
Clicks a toolkit button with the given view ID.
id
- The ID of the button.Clicks a menu (and maybe sub menu).
menuID
- The menu to click.Creates a human readable debug representation of the given element and its children (recursive).
elementList
- The element (can be a list).level
- The nesting level (optional).Finds the logout button on the current page. This is needed since in most pages, the page context is not always know for a given test. A simple 'logoutButton.click()' frequently fails when a new test starts, so we use the explicit $() below instead of the simple page-based approach.
Determines the column index for the given column (field) name for the given domain. Uses the default fieldOrder.
domainClass
- The domain class.columnName
- The column name.Finds the combobox popup list item with the given ID.
id
- The ID.Finds the field label (text) for the given field name.
Note: This is rarely needed. Most Page elements use the TextFieldModule or ReadOnlyFieldModule to find the label.
fieldName
- The field name.Finds the given input text field element on the GUI.
Note: This is rarely needed outside of closures. Most Page elements use the TextFieldModule to find the input field.
fieldName
- The field name.Finds the field value (text) for the given field name.
Note: This is rarely needed. Most Page elements use the TextFieldModule or ReadOnlyFieldModule to find the field text.
fieldName
- The field name.Returns the given dynamic tooltip (needed for toolkit 8.0 tooltips on buttons).
id
- The button ID (toolkit ID).Returns true if the GUI test is running in firefox.
Note: Use this sparingly.
Logs the user in as the given user, if not already logged in. If the user is different from the previous login, then the user will be logged out before the new user is logged in.
_userName
- The user to login as Required.passwordInput
- The password to login with (Default: userName).Logs the user out. Will navigate to the home page if no logout button is found.
Convenience method for general message.properties lookup. This sub-class uses the current locale from the GUI test browser if none is given.
Note: This lookup will flag missing .properties entries.
key
- The key to lookup.locale
- The locale to use for the message. (Default: Current Browser Locale)args
- The replaceable arguments used by the message (if any).Convenience method for general message.properties lookup for fields marked as required. This sub-class uses the current locale from the GUI test browser if none is given.
Note: This lookup will flag missing .properties entries.
key
- The key to lookup.locale
- The locale to use for the message. (Default: Current browser Locale)args
- The replaceable arguments used by the message (if any).Returns true if the given domain has non-zero record count.
domainClass
- The domain class.Send the key(s) without wait to the browser.
Sets a combobox to the given ID setting. Does not use the drop-down.
combobox
- The combobox module to set the value to.id
- The ID of the combobox element to select.Sets a combobox to the given ID setting. Does not use the drop-down.
view
- The combobox view.id
- The ID of the combobox element to select.Checks and sets the given field value. Supports text field and checkbox fields.
fieldName
- The field name.expectedValue
- The expected value.newValue
- The new value.Sets a multi-select combobox to the given list of IDs. Does not use the drop-down.
combobox
- The combobox module to set the value to.values
- The list of values to set (uses the .id element).Sets a multi-select combobox to the given list of IDs. Does not use the drop-down.
view
- The combobox view.values
- The list of values to set (uses the .id element).Initializes the GUI, if needed.
Convenience method to wait a standard delay time (approx 100ms) for the GUI to react.
Note: This should only be used when waitFor is not suitable (rare).
Note: If TRACE logging is enabled, then this method will print an abbreviated stack trace to help you track down where it was called. This will help you decide when a waitFor might be better than a sleep.
multiplier
- The number of standard sleeps to wait for. (Default: 1)Waits for the combobox in a grid to display the input value. Assumes the focus is in the cell with the combobox.
value
- The value in the current combobox editor field.Waits for the combobox in a grid to display the input value. Assumes the focus is in the cell with the combobox.
value
- The value in the current combobox editor field.Wait for a record to to be created in the database.
domainClass
- The domain class.Groovy Documentation