
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ember-cli-page-object
Advanced tools
Helper functions to implement the Page Object pattern in your tests
Represent the screens of your web app as a series of objects. This ember-cli addon ease the construction of these objects on your acceptance tests.
An excerpt from the Selenium Wiki
Within your web app's UI there are areas that your tests interact with. A Page Object simply models these as objects within the test code. This reduces the amount of duplicated code and means that if the UI changes, the fix need only be applied in one place. The pattern was first introduced by the Selenium
You can find more information about this design pattern here:
Install the npm package on your ember-cli project
npm install --save-dev ember-cli-page-object
then import the page-object helper
import PO from '../page-object';
The previous example assumes that your test file is one level deep under
tests/
folder. i.e. tests/acceptance/my-acceptance-test.js
.
Then you can start building your page objects as follows:
var login = PO.build({
visit: PO.visitable('/login'),
userName: PO.fillable('#username'),
password: PO.fillable('#password'),
submit: PO.clickable('#login'),
errorMessage: PO.text('.message')
});
test('Invalid log in', function(assert) {
login
.visit()
.userName('user@example.com')
.password('secret')
.submit();
andThen(function() {
assert.equal(login.errorMessage(), 'Invalid credentials!');
});
});
Built-in support for defining tables and collections:
<table id="users">
<tr>
<td>Jane</td>
<td>Doe</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
var page = PO.build({
visit: PO.visitable('/users'),
users: PO.collection({
itemScope: '#users tr',
item: {
firstName: PO.text('td:nth-of-type(1)'),
lastName: PO.text('td:nth-of-type(2)')
}
})
});
test('show all users', function(assert) {
page.visit();
andThen(function() {
assert.equal(login.users().count(), 2);
assert.equal(login.users(1).firstName(), 'Jane');
assert.equal(login.users(1).lastName(), 'Doe');
assert.equal(login.users(2).firstName(), 'John');
assert.equal(login.users(2).lastName(), 'Doe');
});
});
You can use ES6 destructuring to declutter even more your page definition:
var { visitable, collection, text } = PO;
var page = PO.build({
visit: visitable('/users'),
users: collection({
itemScope: '#users tr',
item: {
firstName: text('td:nth-of-type(1)'),
lastName: text('td:nth-of-type(2)')
}
})
});
Check the DOCUMENTATION for more information.
git clone
this repositorynpm install
bower install
ember server
ember test
ember test --server
ember build
ember-cli-page-object is licensed under the MIT license.
See LICENSE for the full license text.
FAQs
This ember-cli addon eases the construction of page objects on your acceptance and integration tests
The npm package ember-cli-page-object receives a total of 19,931 weekly downloads. As such, ember-cli-page-object popularity was classified as popular.
We found that ember-cli-page-object demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.