@pageobject/standard-selenium
This package implements the PageObjectJS standard API for Selenium.
Installation
yarn add @pageobject/standard-selenium
Peer dependencies
yarn add @pageobject/standard \
selenium-webdriver
TypeScript types
yarn add --dev @types/selenium-webdriver
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 Selenium WebDriver instance
const driver = await new Builder()
.withCapabilities({
browserName: 'chrome',
chromeOptions: {args: ['headless', 'disable-gpu']}
})
.build();
Please make sure you have the latest version of Chrome installed.
Additionally a suitable ChromeDriver is required, in this example we use node-chromedriver
to install it.
require('chromedriver');
Load the website
const page = await SeleniumPage.load('http://example.com/', driver);
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.