Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Insights on Protractor testing

1.100 visualizaciones

Publicado el

Learn some basic recommendations about the e2e testing framework - Protractor

Publicado en: Tecnología
  • Sé el primero en comentar

Insights on Protractor testing

  1. 1. by Dejan Toteff How to build faster e2e tests with Protractor
  2. 2. ● E2E testing framework ● Developed by Google ● Created especially for Angular applications ● Can be used with non Angular sites as well What is Protractor?
  3. 3. ● Continuous integration ● Integration tests ● Test Driven Development Why we need E2E tests?
  4. 4. ● They are slow to write ● Debugging is not a straightforward process ● Short life cycle without update What are the main issues with writing e2e tests?
  5. 5. ● Well-documented ● Integrated with headless and regular browsers ● Easy to set up ● Very powerful API What are the pros of Protractor?
  6. 6. ● It is not build for complex user interactions ● Works at its best only with Chrome ● It doesn’t work well with nested promises What are the cons of Protractor?
  7. 7. Time for some example code
  8. 8. ● Make a habit to use element.all(by...). count() to be sure that you create most suitable element selector. Protractor tips
  9. 9. ● Expect false errors. To confirm an error, run the tests under alternative OS Protractor tips
  10. 10. ● Beware of the async nature of Protractor. ● If something doesn't work as expected go Protractor native, i.e. using .then() Protractor tips
  11. 11. ● Don't abstract the code directly to the PageObject. Often this abstraction lead to errors. Protractor tips
  12. 12. ● Other possible issue is when the element is not in the visible part of the browser’s screen. Protractor tips
  13. 13. ● Avoid use of browser.sleep() right after browser.waitForAngular() Protractor tips
  14. 14. ● If you stumble on an error, that the element you are clicking on is not attached to the document, that means that this is not a testable scenario Protractor tips
  15. 15. ● Once you set the browser size, it persist in your tests until the next browser. setSize() declaration Protractor tips
  16. 16. ● Popups and animation can temporary disable Protractor. Protractor tips
  17. 17. ● The behaviour of .then() method of Protractor’s .map(), .each(), .filter() can be weird. Protractor tips
  18. 18. ● One falsy selection can ruin all the tests. Protractor is hard to debug mainly because in such occasions Protractor tips
  19. 19. ● To make scroll down work, first you need to focus the to the "window" by clicking on any element within the window. Protractor tips
  20. 20. ● Make all your clicks statement either inside the tests, or in the PageObject. Protractor tips
  21. 21. ● measuring-code-coverage-by-protractor ● ● protractor/ Walk the extra mile
  22. 22. https://github. com/selfrefactor/Protractor-testing- patterns Shortlink: Most of slides of this presentation are based on:
  23. 23. Thank you for your attention Protractor testing is actually easy