nemo-page
Version:
View Interface for nemo enhanced with nested locators and collection mechanics.
77 lines (44 loc) • 4.24 kB
Markdown
# Template Object Model
This model is used when you have objects on a page where you want to use a dynamic locator based on underscore templates. An example is if you have a list of accounts with the account id as the id of the item, you can have a locator "#<%= accountId %>".
`_model` - "templateObject"
Extends - [Base Model](base.md)
## Additional locator fields
Like Object, the Template Object model is not a standard locator. The fields associated with an object are determined by the model specified by the `_itemModel` field.
* `_itemModel` - {String} The model to use to process the individual items inside an Array object. This follows the same specifications as `_model`. Additional locator fields will be added to the Array model locator to adhere to the `_itemModel` chosen as well.
* `_locatorTemplate` - {Locator} The locator template to use to find the items. Follows the [underscore template](http://underscorejs.org/#template) format.
## Methods
### collectItem(data, baseOverride)
Collects the data based on the `_itemModel` for the element that matches based on the data passed in.
` data {Object}` - The data to be used by the locator template.
` baseOverride {WebElement}` - An optional override for the base element it uses for collection.
` {Promise}` - Resolves to an the collected data. The format of the resolved data is determined by `_itemModel`
### item(data, baseOverride)
Retrieves the element which matches based on the data passed in.
` data {Object}` - The data to be used by the locator template.
` baseOverride {WebElement}` - An optional override for the base element it uses to find the items.
` {Model}` - Resolves to a page Model object based on the `_itemModel` field representing the item that matches the data passed in.
### isPresent(data, baseOverride)
Checks if the element of the template object is present on the page or not.
` data {Object}` - The data to be used by the locator template.
` baseOverride {WebElement}` - An optional override for the base element it uses to retrieve the element.
` {Promise}` - Resolves to true if the element of the template object is present and false otherwise.
### waitForPresent(data, baseElement)
Waits for an element which matches based on the data passed in to become present on the page.
` data {Object}` - The data to be used by the locator template.
` baseElement {WebElement}` - An optional override for the base element it uses to retrieve the element.
` {Promise}` Resolves sucessfully if the element becomes present within the wait timeout and unsuccessfully if it does not.
### waitForNotPresent(data, baseElement)
Waits for the element which matches based on the data passed in to no longer be present on the page.
` data {Object}` - The data to be used by the locator template.
` baseElement {WebElement}` - An optional override for the base element it uses to retrieve the element.
` {Promise}` Resolves sucessfully if the element becomes not present within the wait timeout and unsuccessfully if it does not.
### waitForDisplayed(baseElement)
Waits for an element which matches based on the data passed in to become displayed on the page.
` data {Object}` - The data to be used by the locator template.
` baseElement {WebElement}` - An optional override for the base element it uses to retrieve the element.
` {Promise}` Resolves sucessfully if the element becomes displayed within the wait timeout and unsuccessfully if it does not.
### waitForNotDisplayed(baseElement)
Waits for the element which matches based on the data passed in to no be displayed on the page. It still, however, expects the element to be present. If you expect the element to no longer be present, use `waitForNotPresent` instead.becomes fixed.
` data {Object}` - The data to be used by the locator template.
` baseElement {WebElement}` - An optional override for the base element it uses to retrieve the element.
` {Promise}` Resolves sucessfully if the element becomes no longer displayed within the wait timeout and unsuccessfully if it does not.