A page object for a rich UI

It is now time to change our UI tests to use the Page Object pattern. The first thing is to create an initial page object that represents the browser. This will encapsulate all the logic about navigation and executing scripts. This way, we can, in the future, replace WebDriver with another tool, if it is necessary. Let's create such an object inside the test/support/ui.js file:

'use strict'; module.exports = function (port, driver) { function uriFor(uiName) { return 'http://localhost:' + port + '/test/' + uiName + '.html'; } return { uriFor: uriFor, goTo: function (uiName) { return driver.get(uriFor(uiName)); }, executeScript: driver.executeScript.bind(driver), executeAsyncScript: driver.executeAsyncScript.bind(driver) ...

Get Learning Behavior-driven Development with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.