WordPress Page Objects to be used on end-to-end tests with Selenium WebDriver
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.babelrc
.editorconfig
.eslintignore
.eslintrc
.gitignore
.npmignore
.npmrc
.travis.yml
LICENSE
README.md
npm-shrinkwrap.json
package.json

README.md

wp-page-objects

npm version build status dependency status

WordPress Page Objects to be used on end-to-end tests with Selenium WebDriver.

Install

npm install wp-page-objects

Usage

Example of front-page assertion:

import assert from 'assert';
import { WebDriverManager } from 'wp-e2e-webdriver';
import { FrontPage } from 'wp-e2e-page-objects';

const manager = new WebDriverManager( 'chrome', {
	baseUrl: 'http://local.wordpress.dev'
} );
const driver = manager.getDriver();

const frontPage = new FrontPage( driver, {
	url: manager.getPageUrl( '/' )
} );

assert( frontPage.sidebar.displayed() );
assert( frontPage.sidebar.widgets.recentPosts.displayed() );
assert( frontPage.sidebar.widgets.recentComments.displayed() );

Login through /wp-login.php:

import { WebDriverManager, WebDriverHelper as helper } from 'wp-e2e-webdriver';

const manager = new WebDriverManager( 'chrome', {
	baseUrl: 'http://local.wordpress.dev'
} );
const driver = manager.getDriver();

helper.clearCookiesAndDeleteLocalStorage()
const wpLogin = new WPLogin( driver, { url: manager.getPageUrl( '/wp-login.php' ) } );
const dashboard = wpLogin.login( 'username', 'password' );

Covered Page Objects

Front-Page

Use twentysixteen theme by default, but class can be extended with you own CSS selector.

  • FrontPage
    • .components.sidebarComponentSidebar
      • .components.widgets.recentPostsComponentWidgetRecentPosts
      • .components.widgets.recentCommentsComponentWidgetRecentComments

WP-Admin

Fresh install with hello-dolly plugin deactivated.

  • WPAdminDashboard
    • .components.welcomePanelComponentWelcomePanel
  • WPAdminPluginInstall
    • .components.filterComponentPluginInstallFilter
  • WPAdminPlugins
    • .components.pluginsListComponentPluginsList
  • WPAdminPostEdit
    • .components.metaBoxCategoriesComponentMetaBoxCategories
    • .components.metaBoxFormatComponentMetaBoxFormat
    • .components.metaBoxPublishComponentMetaBoxPublish
  • WPAdminPostNew
    • .components.metaBoxCategoriesComponentMetaBoxCategories
    • .components.metaBoxFormatComponentMetaBoxFormat
    • .components.metaBoxPublishComponentMetaBoxPublish
  • WPAdminPosts
    • .components.postsListComponentPostsList
  • WPLogin
    • .components.loginForm → ComponentLoginForm

Tests

See README.md on test dir for running tests of this package.