Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Move Fast & Don't Break Things – Ankit Mehta, Google, 2014 GTAC

Slide 4

Slide 4 text

Move Fast & Don't Break Things – Ankit Mehta, Google, 2014 GTAC

Slide 5

Slide 5 text

֩৺ྲྀఔ 爛了了就會接到電話的

Slide 6

Slide 6 text

Manually… IT WORKS™

Slide 7

Slide 7 text

ጺ ⼯工程師的美德 https://github.com/NARKOZ/hacker-scripts

Slide 8

Slide 8 text

Nightwatch.js Browser automated testing done easy.

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

ᐽՍ 幫你把惡惡魔藏起來來,簡化世界

Slide 11

Slide 11 text

Good Parts • Clear Syntax • Controls the Selenium standalone server for you • BrowserStacks / SauceLabs support • Page Objects • Global Objects • Customizable

Slide 12

Slide 12 text

Good Syntax driver.get('http://www.google.com/ncr'); driver.findElement(By.name('q')).sendKeys('webdriver'); driver.findElement(By.name('btnG')).click(); WebDriver

Slide 13

Slide 13 text

Good Syntax Nightwatch client .url('http://www.google.com/ncr') .setValue('[name=q]', 'webdriver') .click('[name=btnG]')

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Usage var loginPage = this.page.login(); loginPage .navigate() .setValue('@account', account.email) .setValue('@password', account.password) .click('@submit')

Slide 16

Slide 16 text

Global Objects const ACCOUNTS = { 'USER': { email: '[email protected]', password: '…' }, }; module.exports = { LOAD_SPEED: 1000, ACCOUNTS: ACCOUNTS };

Slide 17

Slide 17 text

Custom Command page-objects/changePassword.js const commands = { changePassword: function(password, confirmPassword) { this .navigate() .setValue('@password', password) .setValue('@confirmPassword', confirmPassword) .click('@submit'); return this; } };

Slide 18

Slide 18 text

Usage var changePasswordPage = client.page.changePassword(); var newPassword = 'loremipsum'; changePasswordPage .navigate() .wait() .changePassword(newPassword, newPassword);

Slide 19

Slide 19 text

Drawbacks • Setup takes time http://nightwatchjs.org/getingstarted • 拿我的安裝包~ • No promise support • Use not-so-well-documented perform command http:// nightwatchjs.org/api/perform.html

Slide 20

Slide 20 text

DEMO