Methods
attribute(attributeName, selector, options) → {Descriptor}
Gets the value of an attribute from an element
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
attributeName |
string | Name of the attribute to get |
||||||||||||
selector |
string | CSS selector of the element to check |
||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
imageAlternateText: attribute('alt', '.img')
});
assert.equal(page.imageAlternateText, 'Logo');
buildObject()
See https://github.com/san650/ceibo#examples for more info on how Ceibo builders work.
buildSelector(node, targetSelector, options) → {string}
Creates a fully qualified selector
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
node |
Ceibo | Node of the tree |
|||||||||||||||
targetSelector |
string | Specific CSS selector |
|||||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
Full qualified selector
- Type
- string
clickable(selector, options) → {Descriptor}
Creates an action to click an element
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to click |
||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
submit: clickable('button[type=submit]')
});
page.submit();
clickOnText(selector, options) → {Descriptor}
Creates an action to click an element
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to click |
|||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
clickOn: clickOnText('body')
});
page.clickOn('Save');
collection(definition) → {Descriptor}
Creates a component that represents a collection of items
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
definition |
Object | Collection definition Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
users: collection({
itemScope: 'table tr',
item: {
firstName: text('td', { at: 0 })
lastName: text('td', { at: 1 })
}
});
assert.equal(page.users().count(), 2);
assert.equal(page.users(1).firstName, 'John');
assert.equal(page.users(1).lastName, 'Doe');
contains(selector, options) → {Descriptor}
Creates a predicate to validate if an element contains a subtext
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to check |
|||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
<h1> Page Title </h1>
var page = PageObject.create({
titleIncludes: contains('h1')
});
assert.ok(page.titleIncludes('Page'));
count(selector, options) → {Descriptor}
Gets the count of matched elements
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to check |
|||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
imageCount: count('.img')
});
assert.equal(page.imageCount(), 2);
create(definition, options) → {PageObject}
Creates a new PageObject
Parameters:
Name | Type | Description |
---|---|---|
definition |
Object | PageObject definition |
options |
Object | [private] Ceibo options. Do not use! |
Returns:
- Type
- PageObject
Example
var page = PageObject.create({
title: text('.title')
});
assert.equal(page.title, 'Dummy title');
fillable(selector, options) → {Descriptor}
Creates an action to fill in an input
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to fill |
||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
name: fillable('#name')
});
page.name('John Doe');
findElement(node, targetSelector, options) → {Object}
Return a jQuery element (can be an empty jQuery result)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
node |
Ceibo | Node of the tree |
|||||||||||||||
targetSelector |
string | Specific CSS selector |
|||||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
jQuery object
- Type
- Object
findElementWithAssert(node, targetSelector, options) → {Object}
Return a jQuery element or raise an exception if the element doesn't exist
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
node |
Ceibo | Node of the tree |
|||||||||||||||
targetSelector |
string | Specific CSS selector |
|||||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
jQuery object
- Type
- Object
hasClass(cssClass, selector, options) → {Descriptor}
Creates a predicate to validate if an element has a given CSS class
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
cssClass |
string | Name of the CSS class to look for |
|||||||||
selector |
string | CSS selector of the element to check |
|||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
isImageActive: hasClass('is-active', '.img')
});
assert.ok(page.isImageActive(), 'Image is active');
isHidden(selector, options) → {Descriptor}
Creates a predicate to validate if an element is hidden
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to check |
|||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
isImageVisible: isVisible('.img')
});
assert.ok(page.isImageVisible(), 'Image is visible');
isVisible(selector, options) → {Descriptor}
Creates a predicate to validate if an element is visible
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to check |
|||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
isImageVisible: isVisible('.img')
});
assert.ok(page.isImageVisible(), 'Image is visible');
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.
- Source:
- See:
notHasClass(cssClass, selector, options) → {Descriptor}
Creates a predicate to validate if an element doesn't have a given CSS class
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
cssClass |
string | Name of the CSS class to look for |
|||||||||
selector |
string | CSS selector of the element to check |
|||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
isImageDeactivated: notHasClass('is-active', '.img')
});
assert.ok(page.isImageDeactivated(), 'Image is not active');
text(selector, options) → {Descriptor}
Gets the text of the matched element
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to check |
|||||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
title: text('h1')
});
assert.equal(page.title, 'Page title');
var page = PageObject.create({
options: text('li', { multiple: true })
});
assert.deepEqual(page.options, ['lorem', 'ipsum'])
value(selector, options) → {Descriptor}
Gets the value of the matched element
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
selector |
string | CSS selector of the element to check |
||||||||||||
options |
Object | Additional options Properties
|
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
search: value('input')
});
assert.equal(page.search, 'search term');
visitable(path, dynamicSegments, queryParams) → {Descriptor}
Creates an action to load a route
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Full path of the route to visit |
dynamicSegments |
Object | Key and values to use to replace the dynamic segments |
queryParams |
Object | Key and values to use as the Query Params |
- Source:
Returns:
- Type
- Descriptor
Example
var page = PageObject.create({
visit: visitalbe('/users/:user_id')
});
page.visit({ user_id: 10 });