paypal's nemojs and applitools eyes - visual testing with node.js

30
NemoJS and Applitools Eyes Visual Tes*ng with node.js

Upload: applitools

Post on 09-Jan-2017

1.031 views

Category:

Software


2 download

TRANSCRIPT

Page 1: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

NemoJS'and'Applitools'EyesVisual'Tes*ng'with'node.js

Page 2: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Where%does%Nemo%fit?

Page 3: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
Page 4: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
Page 5: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

A"basic"JavaScript"selenium3webdriver"script:

var webdriver = require('selenium-webdriver'), SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;

var server = new SeleniumServer(pathToSeleniumJar, { port: 4444});

server.start();

var driver = new webdriver.Builder(). usingServer(server.address()). withCapabilities(webdriver.Capabilities.firefox()). build();

driver.get('https://www.paypal.com');

Page 6: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

The$same$script$using$Nemo

var Nemo = require('nemo');var nemo = Nemo(function () { nemo.driver.get('https://www.paypal.com');});

Page 7: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

What%does%Nemo%do?• provides*environment.aware*JSON*configura9on

• provides*plugin'API

• provides*access*to*the*webdriver*API

Page 8: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

The$webdriver$API

exposed'as'nemo.driver'and'nemo.wd

Page 9: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Environment*aware*configura1on

• config.json"is"the"defaults"file

• add"overrides"based"on"NODE_ENV

• e.g."NODE_ENV=local"looks"for"local.json

Page 10: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Configura)on*protocols• shortstop(handlers

• env:foo

• path:foo

• argv:foo

• config:foo.bar

Page 11: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

config.json

{ "plugins": { "view": { "module": "nemo-view" }, "util": { "module": "path:plugin/util" } }, "driver": { "browser": "chrome" }}

Page 12: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Nemo%code%pa*erns

Page 13: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Using&nemo*viewit('should execute high level functionality using flow modules', function (done) {

//login nemo.driver.get(nemo.data.baseUrl); util.waitForJSReady(nemo); nemo.view.login.emailWaitVisible().sendKeys('[email protected]'); nemo.view.login.password().sendKeys('11111111'); nemo.view.login.button().click();

//add card success nemo.view.card.numberWaitVisible().sendKeys('123456789012'); nemo.view.card.typeOptionText('Misa'); nemo.view.card.button().click(); nemo.view.card.successWait();

//add card fail nemo.view.card.number().clear(); nemo.view.card.number().sendKeys('1001001'); nemo.view.card.typeOptionText('Misa'); nemo.view.card.button().click(); nemo.view.card.failureWait(); ...

Page 14: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

DRY$pa'ern$(card$module)var Card = function (nemo) { this.nemo = nemo;};

var _enterForm = function (nemo, number, type) { nemo.view.card.numberWaitVisible().clear(); nemo.view.card.number().sendKeys(number); nemo.view.card.typeOptionText(type); return nemo.view.card.button().click();}Card.prototype.addSuccess = function(number, type) { _enterForm(this.nemo, number, type); return this.nemo.view.card.successWait();};

Card.prototype.addFailure = function(number, type) { _enterForm(this.nemo, number, type); return this.nemo.view.card.failureWait();};

module.exports = Card;

Page 15: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

DRY$pa'ern$(navigate$module)var util = require('../util');var Navigate = function (nemo) { this.nemo = nemo;};...Navigate.prototype.logout = function() { this.nemo.view.nav.logoutLink().click(); return this.nemo.view.login.emailWaitVisible();};Navigate.prototype.bank = function() { this.nemo.view.nav.bankLink().click(); return this.nemo.view.bank.numberWaitVisible();};Navigate.prototype.card = function() { this.nemo.view.nav.cardLink().click(); return nemo.view.card.numberWaitVisible();};module.exports = Navigate;

Page 16: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

DRY$pa'ern$(spec$usage)it('should execute high level functionality using flow modules', function (done) { navigate.loginFailure('[email protected]', '11111111'); navigate.loginSuccess('[email protected]', '11111111'); card.addSuccess('0123456789012345', 'Misa'); card.addFailure('1001001', 'Misa'); bank.addSuccess('0432787332', '92929'); bank.addFailure('1001001', '92929'); navigate.logout().then(util.doneSuccess(done), util.doneError(done));});

Page 17: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

countries.js,(dynamic,data)

module.exports = [ { "locality": "en-US", "url": "http://localhost:8000/responsive/us" }, { "locality": "de-DE", "url": "http://localhost:8000/responsive/de" }];

Page 18: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

eyes$spec.js

dd(countries, function () { it('should let me reply to an email for locale {locality}', function (country, done) { //login nemo.driver.get(country.url); nemo.waitForDom(); nemo.view._find('#reply').click(); nemo.view._find('#forward').click(); nemo.view._find('#moveto').click(); nemo.driver.sleep(2000); nemo.view._find('#verify').getText(). then(function (verifyText) { nemo.assert.equal(verifyText, 'replyforwardmoveto'); }). then(function () { done(); }).thenCatch(function (err) { done(err); }); });});

Page 19: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Demo:&Running&our&localized&testVisual'bug'introduced'DE'transla3on

Page 20: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
Page 21: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Incorporate*ApplitoolsCatch&the&visual&bug&in&the&future

Page 22: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Basic&configura-on"eyes": { "module": "path:plugin/eyes", "arguments": [ { "sdk": { "setApiKey": "env:applitools_api_key", "setMatchLevel": "Layout" }, "viewport": { "width": 1200, "height": 600 }, "mock": "env:applitools_mock" } ] }

Page 23: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Demo:&Run&one&test&to&applitools

Page 24: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
Page 25: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Add#responsive#tes-ngnew$config$for$each$form$factor

Page 26: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

phone.json{ "plugins": { "eyes": { "module": "path:plugin/eyes", "arguments": [{ "sdk": { "setBatch": "PHONE", "setMatchLevel": "Layout" }, "viewport": { "width": 620, "height": 400 } }] } }}

Page 27: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

tablet.json{ "plugins": { "eyes": { "module": "path:plugin/eyes", "arguments": [{ "sdk": { "setBatch": "PHONE", "setMatchLevel": "Layout" }, "viewport": { "width": 950, "height": 600 } }] } }}

Page 28: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

Demo:&Visual&tes.ng&along&two&dimensions

Per$country,$per$form$factor

Page 29: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
Page 30: PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js

THANK&YOU

• h#ps://applitools.com/

• h#p://nemo.js.org

• @nemojs_news

• h#ps://github.com/paypal/nemo