web based automation testing on node.js environment
TRANSCRIPT
![Page 1: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/1.jpg)
Web based automation testing on Node.js environment
Kimi
![Page 2: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/2.jpg)
Agenda• Unit Test, TDD and BDD
• Mocha and Chai
• Selenium
• Nightwatch
• GUI vs Non-GUI
• Jenkins integration
• Challenge
• Q&A
![Page 3: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/3.jpg)
Unit Test, TDD and BDD
![Page 4: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/4.jpg)
Unit Test• Simple, quick to write and quick to run
• Integration tests
• Acceptance tests (also called Functional tests)
case 1
case 2
![Page 5: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/5.jpg)
TDD• Test Driven Development (TDD)
• A process for when you write and run your tests
• Test-coverage
![Page 6: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/6.jpg)
BDD• Behaviour Driven Development
• Agile development
• Connecting with TDD
• User story
• Human readable
“An approach to development that improves communication between business and technical teams to create software with business value.”
![Page 7: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/7.jpg)
![Page 8: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/8.jpg)
Chai and Mocha
![Page 9: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/9.jpg)
Chai• https://github.com/chaijs/chai
• BDD / TDD assertion library
• Open Source
• Node.js based
• Expressive language
• Readable style
Simple code:var foo = ‘bar’if foo == ‘bar’
![Page 10: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/10.jpg)
Mocha• https://github.com/mochajs/mocha
• BDD framework
• Open Source
• Node.js based
• Writing User Story
• Export testing report (JSON, HTML et al.)
![Page 11: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/11.jpg)
\describe('math module', function(){
it('should add numbers', function () {
assert.equal((1+1), '2');
assert.strictEqual(127 + 319, 446);
});
it('should sub numbers', function () {
assert.equal((22-1), '21');
assert.strictEqual(127 - 7, 120);
});
});
![Page 12: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/12.jpg)
Selenium
![Page 13: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/13.jpg)
Selenium• http://www.seleniumhq.org
• Open Source
• An automating web applications
• Cross platform
• Support lots of browser vendors
Chrome, Safari et al.
• Support lots of Programming language
Python, Node.js et al.
![Page 14: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/14.jpg)
How it works?
![Page 15: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/15.jpg)
Selenium - working flow
Webdriver, webdriver and webdriver
![Page 16: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/16.jpg)
Selenium - Webdriver
• Install a browser
• Find and install it’s Webdriver
• Can NOT work without webdriver
![Page 17: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/17.jpg)
Selenium RC• Remote Control
• HTTP proxy based
192.168.100.101:12600
![Page 18: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/18.jpg)
Selenium - Demo
• Step 1: Open Safari browser
• Step 2: Maximum window
• Step 3: Search a keyword
• Non Selenium RC
![Page 19: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/19.jpg)
Take a break
![Page 20: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/20.jpg)
Nightwatch
![Page 21: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/21.jpg)
Nightwatch• http://nightwatchjs.org/
• Open Source
• A BDD Web-based auto testing framework
• Node.js base
• A Chai, Mocha and Selenium combination framework
• Selenium RC protocol
• Screenshot when a test fails
![Page 22: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/22.jpg)
How it works?
![Page 23: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/23.jpg)
module.exports = { 'Demo test Google' : function (client) { client .url('http://www.google.com') .waitForElementVisible('body', 1000) .assert.title('Google') .assert.visible('input[type=text]') .setValue('input[type=text]', 'rembrandt van rijn') .waitForElementVisible('button[name=btnG]', 1000) .click('button[name=btnG]') .pause(1000) .assert.containsText('ol#rso li:first-child', 'Rembrandt - Wikipedia') .end(); }};
Nightwatch - Simple Code
Mocha framework
Selenium framework
Chai framework
![Page 24: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/24.jpg)
![Page 25: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/25.jpg)
Nightwatch - Configuration • Webdriver path
• Test result output path
• Test cases path
• Screenshot path
• Selenium RC address
• Browser capabilities
![Page 26: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/26.jpg)
Nightwatch - package.json • Execute CMD: nightwatch -c ./Nightwatch.js --env
safari
• npm run chrome
• npm run sarari
![Page 27: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/27.jpg)
Nightwatch - Tags • nightwatch -c ./Nightwatch.js --tag google
• nightwatch -c ./Nightwatch.js --skiptags google
![Page 28: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/28.jpg)
Demo
![Page 29: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/29.jpg)
Nightwatch - Disabling • nightwatch -c ./Nightwatch.js --env chrome
![Page 30: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/30.jpg)
Demo
![Page 31: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/31.jpg)
Nightwatch - Parallel Running • Tests to be run in parallel
• nightwatch -c ./Nightwatch.js --env chrome, firefox
Test Cases
![Page 32: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/32.jpg)
Get element via CSS/Xpath
![Page 33: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/33.jpg)
Nightwatch - Selector
![Page 34: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/34.jpg)
Chrome - extensions (CSS)
![Page 35: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/35.jpg)
Chrome - extensions (Xpath)
![Page 36: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/36.jpg)
Non GUI testing
![Page 37: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/37.jpg)
PhantomJS - Non GUI testing• Effectively and faster
• Easy implement
• PhantomJS (Ghost driver)
• http://phantomjs.org/
• Friendly to command-line base
• Hard to debug
• Screenshot is necessary
![Page 38: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/38.jpg)
Non GUI testing demo
![Page 39: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/39.jpg)
Jenkins CI integration
![Page 40: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/40.jpg)
Jenkins integration• xUnit Test report
• Path of the test report
• Set PASS/FAIL threshold
![Page 41: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/41.jpg)
Jenkins integration - Slack notification
![Page 42: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/42.jpg)
Challenge
![Page 43: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/43.jpg)
Challenge• Microsoft IE
Unix-like interacte with Windows
• macOS Safari
Need a Mac device
• AWS command-line base platform
Need a GUI bridge
• Mobile platform (RWD)
Fix Browser resolution? or Use Appium framework?
![Page 44: Web based automation testing on Node.js environment](https://reader036.vdocuments.site/reader036/viewer/2022062820/58a41b311a28abec1a8b4fbd/html5/thumbnails/44.jpg)
Q & A