Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Web based automation testing on
Node.js environment
Kimi
Agenda
• Unit Test, TDD and BDD
• Mocha and Chai
• Selenium
• Nightwatch
• GUI vs Non-GUI
• Jenkins integration
• Challeng...
Unit Test, TDD and BDD
Unit Test
• Simple, quick to write and quick to run
• Integration tests
• Acceptance tests (also called Functional tests)
...
TDD
• Test Driven Development (TDD)
• A process for when you write and run your tests
• Test-coverage
BDD
• Behaviour Driven Development
• Agile development
• Connecting with TDD
• User story
• Human readable
“An approach to...
Chai and Mocha
Chai
• https://github.com/chaijs/chai
• BDD / TDD assertion library
• Open Source
• Node.js based
• Expressive language
• ...
Mocha
• https://github.com/mochajs/mocha
• BDD framework
• Open Source
• Node.js based
• Writing User Story
• Export testi...
describe('math module', function(){
it('should add numbers', function () {
assert.equal((1+1), '2');
assert.strictEqual(12...
Selenium
Selenium
• http://www.seleniumhq.org
• Open Source
• An automating web applications
• Cross platform
• Support lots of bro...
How it works?
Selenium - working flow
Webdriver, webdriver and webdriver
Selenium - Webdriver
• Install a browser
• Find and install it’s Webdriver
• Can NOT work without webdriver
Selenium RC
• Remote Control
• HTTP proxy based
192.168.100.101:12600
Selenium - Demo
• Step 1: Open Safari browser
• Step 2: Maximum window
• Step 3: Search a keyword
• Non Selenium RC
Take a break
Nightwatch
Nightwatch
• http://nightwatchjs.org/
• Open Source
• A BDD Web-based auto testing framework
• Node.js base
• A Chai, Moch...
How it works?
module.exports = {
'Demo test Google' : function (client) {
client
.url('http://www.google.com')
.waitForElementVisible('b...
Nightwatch - Configuration
• Webdriver path
• Test result output path
• Test cases path
• Screenshot path
• Selenium RC ad...
Nightwatch - package.json
• Execute CMD: nightwatch -c ./Nightwatch.js --env safari
• npm run chrome
• npm run sarari
Nightwatch - Tags
• nightwatch -c ./Nightwatch.js --tag google
• nightwatch -c ./Nightwatch.js --skiptags google
Demo
Nightwatch - Disabling
• nightwatch -c ./Nightwatch.js --env chrome
Demo
Nightwatch - Parallel Running
• Tests to be run in parallel
• nightwatch -c ./Nightwatch.js --env chrome, firefox
Test Cas...
Get element via
CSS/Xpath
Nightwatch - Selector
Chrome - extensions (CSS)
Chrome - extensions (Xpath)
Non GUI testing
PhantomJS - Non GUI testing
• Effectively and faster
• Easy implement
• PhantomJS (Ghost driver)
• http://phantomjs.org/
•...
Non GUI testing demo
Jenkins CI integration
Jenkins integration
• xUnit Test report
• Path of the test report
• Set PASS/FAIL threshold
Jenkins integration - Slack notification
Challenge
Challenge
• Microsoft IE
Unix-like interacte with Windows
• macOS Safari
Need a Mac device
• AWS command-line base platfor...
Q & A
Web based automation testing on Node.js environment
Web based automation testing on Node.js environment
Prochain SlideShare
Chargement dans…5
×

Web based automation testing on Node.js environment

145 vues

Publié le

An introduction of Nightwatch.

Publié dans : Technologie
  • Soyez le premier à commenter

Web based automation testing on Node.js environment

  1. 1. Web based automation testing on Node.js environment Kimi
  2. 2. Agenda • Unit Test, TDD and BDD • Mocha and Chai • Selenium • Nightwatch • GUI vs Non-GUI • Jenkins integration • Challenge • Q&A
  3. 3. Unit Test, TDD and BDD
  4. 4. Unit Test • Simple, quick to write and quick to run • Integration tests • Acceptance tests (also called Functional tests) case 1 case 2
  5. 5. TDD • Test Driven Development (TDD) • A process for when you write and run your tests • Test-coverage
  6. 6. 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.”
  7. 7. Chai and Mocha
  8. 8. 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’
  9. 9. Mocha • https://github.com/mochajs/mocha • BDD framework • Open Source • Node.js based • Writing User Story • Export testing report (JSON, HTML et al.)
  10. 10. 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); }); });
  11. 11. Selenium
  12. 12. 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.
  13. 13. How it works?
  14. 14. Selenium - working flow Webdriver, webdriver and webdriver
  15. 15. Selenium - Webdriver • Install a browser • Find and install it’s Webdriver • Can NOT work without webdriver
  16. 16. Selenium RC • Remote Control • HTTP proxy based 192.168.100.101:12600
  17. 17. Selenium - Demo • Step 1: Open Safari browser • Step 2: Maximum window • Step 3: Search a keyword • Non Selenium RC
  18. 18. Take a break
  19. 19. Nightwatch
  20. 20. 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
  21. 21. How it works?
  22. 22. 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
  23. 23. Nightwatch - Configuration • Webdriver path • Test result output path • Test cases path • Screenshot path • Selenium RC address • Browser capabilities
  24. 24. Nightwatch - package.json • Execute CMD: nightwatch -c ./Nightwatch.js --env safari • npm run chrome • npm run sarari
  25. 25. Nightwatch - Tags • nightwatch -c ./Nightwatch.js --tag google • nightwatch -c ./Nightwatch.js --skiptags google
  26. 26. Demo
  27. 27. Nightwatch - Disabling • nightwatch -c ./Nightwatch.js --env chrome
  28. 28. Demo
  29. 29. Nightwatch - Parallel Running • Tests to be run in parallel • nightwatch -c ./Nightwatch.js --env chrome, firefox Test Cases
  30. 30. Get element via CSS/Xpath
  31. 31. Nightwatch - Selector
  32. 32. Chrome - extensions (CSS)
  33. 33. Chrome - extensions (Xpath)
  34. 34. Non GUI testing
  35. 35. 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
  36. 36. Non GUI testing demo
  37. 37. Jenkins CI integration
  38. 38. Jenkins integration • xUnit Test report • Path of the test report • Set PASS/FAIL threshold
  39. 39. Jenkins integration - Slack notification
  40. 40. Challenge
  41. 41. 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?
  42. 42. Q & A

×