Extend
Methods
You can create custom helpers by creating Ceibo descriptors. (Ceibo is a small library for parsing trees. You can check it out here).
findOne
addon/-private/extend/find-one.js:38-44
Parameters
pageObjectNodeCeibo Node of the treetargetSelectorstring Specific CSS selectoroptionsObject Additional optionsoptions.resetScopeboolean Do not use inherited scopeoptions.containsstring Filter by using :contains(‘foo’) pseudo-classoptions.lastboolean Filter by using :last pseudo-classoptions.visibleboolean Filter by using :visible pseudo-classoptions.testContainerString Context where to search elements in the DOMoptions.atnumber Filter by index using :eq(x) pseudo-classoptions.pageObjectKeyString Used in the error message when the element is not found
Examples
import { findOne } from 'ember-cli-page-object/extend';
import { getter } from 'ember-cli-page-object/macros';
export default function isDisabled(selector, options = {}) {
return getter(function() {
return findOne(this, selector, options).disabled;
});
}
findMany
addon/-private/extend/find-many.js:38-44
Parameters
pageObjectNodeCeibo Node of the treetargetSelectorstring Specific CSS selectoroptionsObject Additional optionsoptions.resetScopeboolean Do not use inherited scopeoptions.containsstring Filter by using :contains(‘foo’) pseudo-classoptions.visibleboolean Filter by using :visible pseudo-classoptions.testContainerString Context where to search elements in the DOMoptions.pageObjectKeyString Used in the error message when the element is not found
Examples
import { findMany } from 'ember-cli-page-object/extend';
import { getter } from 'ember-cli-page-object/macros';
export default function count(selector, options = {}) {
return getter(function() {
return findMany(this, selector, options).length;
});
}
findElementWithAssert
addon/-private/extend/find-element-with-assert.js:38-44
Note: in the v2 series we are going to deprecate findElementWithAssert. It’s recommended to migrate to use findOne instead.
In order to ease the migration, you may find useful the find-one codemod to perform the migration.
Parameters
pageObjectNodeCeibo Node of the treetargetSelectorstring Specific CSS selectoroptionsObject Additional optionsoptions.resetScopeboolean Do not use inherited scopeoptions.containsstring Filter by using :contains(‘foo’) pseudo-classoptions.lastboolean Filter by using :last pseudo-classoptions.visibleboolean Filter by using :visible pseudo-classoptions.multipleboolean Specify if built selector can match multiple elements.options.testContainerString Context where to search elements in the DOMoptions.atnumber Filter by index using :eq(x) pseudo-classoptions.pageObjectKeyString Used in the error message when the element is not found
Examples
import { findElementWithAssert } from 'ember-cli-page-object/extend';
import { getter } from 'ember-cli-page-object/macros';
export default function count(selector, options = {}) {
return getter(function() {
return findElementWithAssert(this, selector, options).is(':disabled');
});
}
findElement
addon/-private/extend/find-element.js:36-42
Note: in the v2 series we are going to deprecate findElement. It’s recommended to migrate to use findMany instead.
Parameters
pageObjectNodeCeibo Node of the treetargetSelectorstring Specific CSS selectoroptionsObject Additional optionsoptions.resetScopeboolean Do not use inherited scopeoptions.containsstring Filter by using :contains(‘foo’) pseudo-classoptions.atnumber Filter by index using :eq(x) pseudo-classoptions.lastboolean Filter by using :last pseudo-classoptions.visibleboolean Filter by using :visible pseudo-classoptions.multipleboolean Specify if built selector can match multiple elements.options.testContainerString Context where to search elements in the DOM
Examples
import { findElement } from 'ember-cli-page-object/extend';
import { getter } from 'ember-cli-page-object/macros';
export default function isDisabled(selector, options = {}) {
return getter(function() {
return findElement(this, selector, options).is(':disabled');
});
}
Usage Example:
const page = create({
scope: '.page',
isAdmin: disabled('#override-name')
});
page.isAdmin will look for elements in the DOM that match “.page
#override-name” and check if they are disabled.