Create
Methods
create
addon/-private/create.js:99-138
Creates a new PageObject.
By default, the resulting PageObject will respond to:
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
definition
Object PageObject definitiondefinition.context
[Object] A test’sthis
context
options
Object [private] Ceibo options. Do not use!definitionOrUrl
definitionOrOptions
optionsOrNothing
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.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