1.0.0-beta-4 • Published 6 years ago

@pageobject/standard-puppeteer v1.0.0-beta-4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

@pageobject/standard-puppeteer Package Version Build Status Coverage Status

This package implements the PageObjectJS standard API for Puppeteer.

Installation

yarn add @pageobject/standard-puppeteer

Peer dependencies

yarn add @pageobject/standard \
         puppeteer

TypeScript types

yarn add --dev @types/puppeteer

API

Please find the API documentation here.

Usage

In this example we load the website example.com and test if the actual page title corresponds to the expected page title.

The complete code of this example can be found in the file example.js.

Create a new Puppeteer Browser instance

const browser = await launch();

Load the website

const page = await PuppeteerPage.load('http://example.com/', browser);

Create a page object

class Root extends StandardPageObject {
  get selector() {
    return ':root';
  }
}

const root = new Root(page);

Run the assertion using the page object

assert.strictEqual(await root.getPageTitle(), 'Example Domain');

Built by (c) Clemens Akens. Released under the terms of the MIT License.