A platform- and framework-independent UI test automation library.
Latest commit 0e319b1 Apr 26, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode feat: complete api restructuring (#127) Feb 23, 2018
@pageobject v11.2.1 Apr 25, 2018
docs docs(all): improve readme structure and examples (#227) Apr 24, 2018
.editorconfig build(all): improve building speed by using make (#157) Mar 8, 2018
.gitignore feat(todomvc): add todomvc example project (#214) Apr 23, 2018
.markdownlint.json docs(all): improve api documentation (#166) Mar 9, 2018
.node-version feat: add core and selenium-adapter packages Oct 27, 2017
.prettierignore build(all): improve building speed by using make (#157) Mar 8, 2018
.prettierrc build: improve project setup (#118) Feb 6, 2018
.travis.yml feat(all): a new api (#176) Apr 3, 2018
CHANGELOG.md v11.2.1 Apr 25, 2018
LICENSE docs(all): update copyright notice (#168) Mar 9, 2018
Makefile docs(todomvc): add example images to readme (#221) Apr 23, 2018
README.md docs(all): improve readme structure and examples (#227) Apr 24, 2018
commitlint.config.js build(all): add support for dependabot commits Apr 17, 2018
lerna.json v11.2.1 Apr 25, 2018
package.json build(all): bump lerna from 2.10.2 to 2.11.0 (#228) Apr 25, 2018
protractor.config.js build(all): optimize build process (#217) Apr 22, 2018
tsconfig.json feat: add core and selenium-adapter packages Oct 27, 2017
tslint.json docs: update typedoc to v0.10.0 (#106) Feb 1, 2018
typedoc.js build(all): optimize build process (#217) Apr 22, 2018
wallaby.js build(all): optimize build process (#217) Apr 22, 2018
yarn.lock build(puppeteer): bump @types/puppeteer from 1.2.1 to 1.2.2 (#229) Apr 25, 2018

README.md

PageObjectJS

Build Status Coverage Status TypeScript

A platform- and framework-independent UI test automation library.

Getting started

You can find the complete code of all examples here. To run them, you need Node.js version 8 or higher.

Example 1: Writing your first automated web UI test

In this example we write a test which opens the website example.com and asserts its page title:

function example(test, app) {
  test
    .perform(app.page.goto('http://example.com/'))
    .assert(app.page.getTitle(), is('Example Domain'));
}

We also need to write our first component, which currently serves only to give us access to its page object:

// ES2015 notation
class App extends WebComponent {
  get selector() {
    return ':root';
  }
}
// TypeScript/Babel notation
class App extends WebComponent {
  selector = ':root';
}

The test is performed in Node.js without a real browser using jsdom:

const adapter = new JSDOMAdapter();

await Test.run(new App(adapter), 10, example);

Example 2: Using a real browser

To use a real browser instead of jsdom, we have to choose another adapter.

Adapters for the following test automation solutions are currently available:

We only need to change one line to run the above test in a headless Chrome:

const adapter = await PuppeteerAdapter.create();

Example 3: Writing and using another component

Next we write a component for the "more information" link:

class Link extends WebComponent {
  get selector() {
    return 'a';
  }
}

We declare the link as a descendant of the app component:

class App extends WebComponent {
  get selector() {
    return ':root';
  }

  get moreInformationLink() {
    return new Link(this.adapter, this);
  }
}

Now we extend our existing test so that it asserts the link text and then clicks on the link:

function example(test, app) {
  test
    .perform(app.page.goto('http://example.com/'))
    .assert(app.page.getTitle(), is('Example Domain'))
    .assert(app.moreInformationLink.getText(), is('More information...'))
    .perform(app.moreInformationLink.click());
}

Further examples

@pageobject/todomvc

An exemplary test suite for the popular TodoMVC application.

Packages

@pageobject/base

A declarative API as a basis for platform- and framework-independent UI test automation.

@pageobject/web

A declarative API for framework-independent web UI test automation.

@pageobject/protractor

A web API adapter for Protractor.

@pageobject/puppeteer

A web API adapter for Puppeteer.

@pageobject/selenium-webdriver

A web API adapter for Selenium.


Copyright (c) 2017-present, Clemens Akens. Released under the terms of the MIT License.