February 2015
Intermediate to advanced
392 pages
8h 12m
English
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) ...Read now
Unlock full access