Helpers
Methods
buildSelector
Builds a CSS selector from a target selector and a PageObject or a node in a PageObject, along with optional parameters.
Parameters
nodeCeibo Node of the treetargetSelectorstring 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-class
Examples
const component = PageObject.create({ scope: '.component'});
buildSelector(component, '.my-element');
// returns '.component .my-element'
const page = PageObject.create({});
buildSelector(page, '.my-element', { at: 0 });
// returns '.my-element:eq(0)'
const page = PageObject.create({});
buildSelector(page, '.my-element', { contains: "Example" });
// returns ".my-element :contains('Example')"
const page = PageObject.create({});
buildSelector(page, '.my-element', { last: true });
// returns '.my-element:last'
Returns string Fully qualified selector
findElement
Returns a jQuery element (can be an empty jQuery result)
Parameters
nodeCeibo 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
Returns Object jQuery object
findElementWithAssert
Returns a jQuery element matched by a selector built from parameters
Parameters
nodeCeibo Node of the treeoptions.pageObjectKeyString Used in the error message when the element is not foundoptionsObject 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-class
targetSelectorstring Specific CSS selector
Returns Object jQuery object
getContext
Return a test context if one was provided during create()
Parameters
nodeCeibo Node of the tree
Returns ** The test’s this context, or null
getRoot
Return the root of a node’s tree
Parameters
nodeCeibo Node of the tree
Returns Ceibo node - Root node of the tree
normalizeText
Trim whitespaces at both ends and normalize whitespaces inside text
Due to variations in the HTML parsers in different browsers, the text returned may vary in newlines and other white space.
Parameters
text