Create
Methods
Table of Contents
create
Creates a new PageObject.
By default, the resulting PageObject will respond to:
- Actions: click, clickOn, fillIn, select
- Predicates: contains, isHidden, isPresent, isVisible
- Queries: text
definition
can include a key context
, which is an
optional integration test this
context.
If a context is passed, it is used by actions, queries, etc.,
as the this
in this.$()
.
If no context is passed, the global Ember acceptence test helpers are used.
Parameters
definitionOrUrl
definitionOrOptions
optionsOrNothing
definition
Object PageObject definitiondefinition.context
Object? A test’sthis
context
options
Object [private] Ceibo options. Do not use!
Examples
// <div class="title">My title</div>
import PageObject, { text } from 'ember-cli-page-object';
const page = PageObject.create({
title: text('.title')
});
assert.equal(page.title, 'My title');
// <div id="my-page">
// My super text
// <button>Press Me</button>
// </div>
const page = PageObject.create({
scope: '#my-page'
});
assert.equal(page.text, 'My super text');
assert.ok(page.contains('super'));
assert.ok(page.isPresent);
assert.ok(page.isVisible);
assert.notOk(page.isHidden);
assert.equal(page.value, 'my input value');
// clicks div#my-page
page.click();
// clicks button
page.clickOn('Press Me');
// fills an input
page.fillIn('name', 'John Doe');
// selects an option
page.select('country', 'Uruguay');
Defining path
const usersPage = PageObject.create('/users');
// visits user page
usersPage.visit();
const userTasksPage = PageObject.create('/users/tasks', {
tasks: collection({
itemScope: '.tasks li',
item: {}
});
});
// get user's tasks
userTasksPage.visit();
userTasksPage.tasks().count
Returns PageObject