Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nightwatch.js Introduction

Nightwatch.js Introduction

Liang Bin Hsueh

November 18, 2016
Tweet

More Decks by Liang Bin Hsueh

Other Decks in Programming

Transcript

  1. End-to-End (E2E) testing End-to-end testing involves ensuring that that integrated

    components of an application function as expected. For example, a simplified end- to-end testing of an email application might involve: • Logging in to the application • Accessing the inbox • Opening and closing the mailbox • Composing, forwarding or replying to email • Checking the sent items • Logging out of the application
  2. Good Parts • Clear Syntax • Controls the Selenium standalone

    server for you • BrowserStacks / SauceLabs support • Page Objects • Global Objects • Customizable
  3. Page Object module.exports = { url: function() { return this.api.launchUrl;

    }, elements: { account: { selector: 'input[name="account"]' }, password: { selector: 'input[name="password"]' }, submit: { selector: 'button[type="submit"]' } }, commands: [commands] }; page-objects/login.js
  4. Global Objects const ACCOUNTS = { 'USER': { email: '[email protected]',

    password: '…' }, }; module.exports = { LOAD_SPEED: 1000, ACCOUNTS: ACCOUNTS };
  5. Custom Command page-objects/changePassword.js const commands = { changePassword: function(password, confirmPassword)

    { this .navigate() .setValue('@password', password) .setValue('@confirmPassword', confirmPassword) .click('@submit'); return this; } };
  6. Drawbacks • Setup takes time http://nightwatchjs.org/getingstarted • 拿我的安裝包~ • No

    promise support • Use not-so-well-documented perform command http:// nightwatchjs.org/api/perform.html