wc-e2e-page-objects
v0.11.0
Published
WooCommerce Page Objects to be used on end-to-end tests with Selenium WebDriver
Downloads
31
Readme
wc-e2e-page-objects
WooCommerce Page Objects to be used on end-to-end tests with Selenium WebDriver.
Install
npm install wc-page-objects
Docs
Usage
Example:
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import test from 'selenium-webdriver/testing';
import { WebDriverManager, WebDriverHelper as helper } from 'wp-e2e-webdriver';
import { ShopPage, CartPage } from 'wc-e2e-page-objects';
chai.use( chaiAsPromised );
const assert = chai.assert;
let manager;
let driver;
test.describe( 'Cart page', function() {
test.before( 'open browser', function() {
manager = new WebDriverManager( 'chrome', { baseUrl: 'http://local.wordpress.dev' } );
driver = manager.getDriver();
helper.clearCookiesAndDeleteLocalStorage( driver );
} );
test.it( 'should displays no item in the cart', () => {
const cartPage = new CartPage( driver, { url: manager.getPageUrl( '/cart' ) } );
assert.eventually.equal( cartPage.hasNoItem(), true );
} );
test.it( 'should adds the product to the cart when "Add to cart" is clicked', () => {
const shopPage = new ShopPage( driver, { url: manager.getPageUrl( '/shop' ) } );
assert.eventually.equal( shopPage.addProductToCart( 'Flying Ninja' ), true );
assert.eventually.equal( shopPage.addProductToCart( 'Happy Ninja' ), true );
const cartPage = new CartPage( driver, { url: manager.getPageUrl( '/cart' ) } );
assert.eventually.equal( cartPage.hasItem( 'Flying Ninja' ), true );
assert.eventually.equal( cartPage.hasItem( 'Happy Ninja' ), true );
} );
test.after( 'quit browser', () => {
manager.quitBrowser();
} );
} );