SlideShare a Scribd company logo
Selenium WebDriverJS based framework for
automated testing of Angular 1.x/2.x applications
OLEKSANDR KHOTEMSKYI
xotabu4.github.io
 Julie Ralph(Google) is one of the main
contributors, made first commits in
January 2013
 Created as an answer to question:
”How to make end to end tests for
AngularJS applications easier?”
 Now ProtractorJS reached version 4.x,
with over 1300 commits, 5700 GitHub
stars, 200 contributors
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для браузерной автоматизации
 JS is one of the most popular languages today, and
TypeScript is as primary in Angular 2.0
https://dou.ua/lenta/articles/language-rating-jan-2016/
JAVA C# JavaScript PHP PythonC++ Ruby
 Easier than Java
 Thousands of libraries already exist for JS/NodeJS. Friendly
community, tons of open source code. Package manager already
included in NodeJS
 Much easier common code like JSON parsing, sending HTTP requests,
and others
 Duck-typing, monkey-patching
 Tools are smaller, and project start is faster
 Newest versions of TypeScript or ECMAScript 6 makes code much
easier to write and understand
 Same language for front-end, back-end and tests means that same code
execution environment
 Developed by Microsoft team
 Superset of JavaScript (includes JavaScript)
 Compiles to JavaScript (ECMAScript 3, 5 or 6)
 Optional types! This allows to have autocomplete in IDE
 Easier refactoring of code
 Has features that not yet in JavaScript specification
(@Annotations, async/await)
 Compilation errors, instead of runtime errors in JavaScript
ProtractorJS Java Selenium WebDriver
High-level framework Low-level automation library (not framework)
Uses script languages: TypeScript or JavaScript
or both same time
Uses Java
JasimineJS (test runner and assertions),
SauceLabs/BrowserStack integration, basic
reporting, interactive debugger, command line
parameters, configuration files

Node Package Manager shows ~628 results for
‘protractor’
Maven shows ~422 results for ‘selenium
webdriver’
Asynchronous, uses own control-flow, and
Promises objects
Synchronous, traditional approach
Ability to run tests in parallel Parallel running should be done with additional
libraries/frameworks
PageObjects are just objects with attributes and
functions
PageObjects require @FindBy annotations and
PageObjectFactory usage.
Plugins. Extra element locators. Mobile browsers
support (with Appium).
Mobile browsers support.
Test Runner
(JasmineJS,
Cucumber …)
ProtractorJS
Selenium JavaScript official
bindings
NodeJS environment
Test Runner
extensions
Selenium Standalone Server (JAVA)
Other JS modules
HTTP
JSON
ChromeDriver GeckoDriver EdgeDriver SafariDriver Other drivers
• Runs on NodeJS 4.x, 5.x, 6.x
• Can be used with different Test Runners (JasmineJS, CucumberJS, Mocha, others)
• Can connect to browser using WebDriver server or directly (Chrome and Firefox only)
• Supports all browsers that WebDriver does: Chrome, Firefox, Edge, Safari, Opera,
PhantomJS and mobile
• Angular 1.x and Angular 2.x ready!
One of the key features of ProtractorJS that it is uses same JSON WebDriver Wire protocol as
other language bindings.
This code will be executed as 3 separate JSON WebDriver Wire Protocol commands:
Synchronizing with
AngularJS application
Locating element on the
page
Sending ‘click’ action for
element
• Protractor uses ‘Wrapper’ pattern to add own features to standard WebDriver, WebElement, Locators objects
Browser(WebDriver instance)
+
Inherited from WebDriver
• getProcessedConfig
• forkNewDriverInstance
• restart
• useAllAngular2AppRoots
• waitForAngular
• findElement
• findElements
• isElementPresent
• addMockModule
• clearMockModules
• removeMockModule
• getRegisteredMockModules
• get
• refresh
• navigate
• setLocation
• getLocationAbsUrl
• debugger
• enterRepl
• pause
• wrapDriver
actions
touchActions
executeScript
executeAsyncScri
pt
call
wait
sleep
getPageSource
close
getCurrentUrl
getTitle
takeScreenshot
switchTo
ElementFinder
+
Inherited from WebElement• then
• clone
• locator
• getWebElement
• all
• element
• $$
• $
• isPresent
• isElementPresent
• evaluate
• allowAnimations
• equals
• getDriver
• getId
• getRawId
• serialize
• findElement
• click
• sendKeys
• getTagName
• getCssValue
• getAttribute
• getText
• getSize
• getLocation
• isEnabled
• isSelected
• submit
• clear
• isDisplayed
• takeScreenshot
Protractor Locators
+
Inherited from WebDriver Locators• addLocator
• binding
• exactBinding
• model
• buttonText
• partialButtonText
• repeater
• exactRepeater
• cssContainingText
• options
• deepCss
• className
• css
• id
• linkText
• js
• name
• partialLinkText
• tagName
• xpath
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для браузерной автоматизации
 JavaScript is single threaded (mostly)
 To have possibility to do multiple tasks at once – JavaScript run them
all in single thread, and quickly switch between them
 Async tasks are running in isolation. To make execution step by step
– callbacks are used
 Callbacks are just functions, that will be called when async function
is finished. It is like – “call this when you are done”. You can pass any
arguments to them
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для браузерной автоматизации
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для браузерной автоматизации
 Pattern to avoid callback hell, extension of callbacks
 Almost every function from API returns special object – Promise
 Promise is a object, that will be resolved to a value (any), or
rejected if value can’t be returned
 Do not try to write in synchronous manner! You
should think differently when writing async code
 When you asserting results – promises
automatically resolved. Do not worry to resolve
promise before assertion
 To wait something on the page – use
browser.wait() or browser.sleep()
 ES7 features are on their way! async/await will
make our life much easier
 Be brave and good luck
QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для браузерной автоматизации
https://gist.github.com/Xotabu4/f26afb9e24397c9d059bb984d30a6b0a
Example of simple test case
JAVA + Pure Selenium JAVA + JUNIT
TypeScript + ProtractorJS + JasmineJS
https://gist.github.com/Xotabu4/dcfe83bc98ad304f58f3b05de9cd6c69
https://gist.github.com/Xotabu4/79ece1d104f2557a70cd079b62f46f45
Example of simple pageObject pattern usage
JAVA + Selenium PageObjectFactory (@FindBy)
TypeScript + ProtractorJS
https://gist.github.com/Xotabu4/a9334f22933d1d6a16c820ccb4bd6635
And useful links:
 Protractor site: http://www.protractortest.org
 Promises, WebDriver Control Flow documentation:
http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/promise.html
 Gitter chat: https://gitter.im/angular/protractor
 StackOverflow(top questions): http://stackoverflow.com/questions/tagged/protractor?sort=votes&pageSize=20
 GitHub: https://github.com/angular/protractor
 TypeScript documentation: https://www.typescriptlang.org/docs/tutorial.html
 ES6 features: http://es6-features.org/
 Protractor TypeScript example: https://github.com/angular/protractor/tree/master/exampleTypescript
OLEKSANDR KHOTEMSKYI
xotabu4.github.io 2016

More Related Content

PPTX
QA Fest 2016. Роман Горин. Введение в системы распознавания речи глазами тест...
PPTX
QA Fes 2016. Артем Быковец. Как выживать тестировщику в Agile среде
PPTX
Increase selenium tests stability via java script
PDF
КОСТЯНТИН НАТАЛУХА «Setup and run automated test framework for Android applic...
PPT
Jasmine presentation Selenium Camp 2013
PPTX
ОЛЕКСІЙ ОСТАПОВ «Найкрутіші особливості автоматизації на Playwright Python» K...
PDF
Ruin your life using robot framework
PPTX
QA Challenge Accepted 4.0 - Cypress vs. Selenium
QA Fest 2016. Роман Горин. Введение в системы распознавания речи глазами тест...
QA Fes 2016. Артем Быковец. Как выживать тестировщику в Agile среде
Increase selenium tests stability via java script
КОСТЯНТИН НАТАЛУХА «Setup and run automated test framework for Android applic...
Jasmine presentation Selenium Camp 2013
ОЛЕКСІЙ ОСТАПОВ «Найкрутіші особливості автоматизації на Playwright Python» K...
Ruin your life using robot framework
QA Challenge Accepted 4.0 - Cypress vs. Selenium

What's hot (20)

PDF
How To Use Selenium Successfully
PPTX
Automated Testing using JavaScript
PPTX
Robot Framework
PDF
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
PPTX
Java Development EcoSystem
PPTX
Why you should switch to Cypress for modern web testing?
PDF
Continuous Testing Meets the Classroom at Code.org
PDF
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
PDF
Barcamp Bangkhen :: Robot Framework
PDF
Rspec and Capybara Intro Tutorial at RailsConf 2013
PDF
AngularJS and Protractor
PDF
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
PDF
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
PPTX
Why test automation projects are failing
PPT
Next generation frontend tooling
PPTX
Protractor for angularJS
PDF
Robot Framework Dos And Don'ts
PPTX
TGT#13 - UI Tests Automation Framework in Evolve EDM – Case Study - Mateusz R...
PDF
Robot framework - Lord of the Rings
PDF
Introduction to Robot Framework
How To Use Selenium Successfully
Automated Testing using JavaScript
Robot Framework
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Java Development EcoSystem
Why you should switch to Cypress for modern web testing?
Continuous Testing Meets the Classroom at Code.org
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
Barcamp Bangkhen :: Robot Framework
Rspec and Capybara Intro Tutorial at RailsConf 2013
AngularJS and Protractor
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Why test automation projects are failing
Next generation frontend tooling
Protractor for angularJS
Robot Framework Dos And Don'ts
TGT#13 - UI Tests Automation Framework in Evolve EDM – Case Study - Mateusz R...
Robot framework - Lord of the Rings
Introduction to Robot Framework
Ad

Viewers also liked (20)

PPTX
QA Fest 2016. Александр Неделяев. Браузерные помощники тестировщика
PDF
QA Fes 2016. Алексей Виноградов. Page Objects: лучше проще, да лучшe
PPTX
QA Fes 2016. Иван Пашко. Теория Дарвина в тестах. Эволюция Wait-ов.
PPTX
QA Fest 2016. Андрей Мясников. Тест-дизайн для чайников
PDF
QA Fes 2016. Анастасия Асеева. Роль тестирования в Devops
PPTX
QA Fest 2016. Алексей Виноградов. Цель тестирования. А на самом деле?
PPTX
QA Fest 2016. Татьяна Люлюченко. Немного о мобильных браузерах
PPTX
Сергей Семашко "End to end test: cheap and effective"
PPTX
QA Fes 2016. Анна Карпенко. Специфика тестирования мобильных приложений или к...
PDF
QA Fest 2016. Денис Яременко. Как облегчить процесс мобильного тестирования
PDF
QA Fes 2016. Василий Сливка. 10 лучших практик для тестирования мобильных при...
PDF
QA Fes 2016. Катерина Овеченко & Михаил Дырда. История одной авантюры: наш не...
PDF
QA Fest 2016. Антон Серпутько. Автоматизация запуска тестов с помощью Jenkins...
PPTX
QA Fes 2016. Игорь Любин. Об автоматическом тестировании бэкенда в MediaMarkt
PDF
Easy tests with Selenide and Easyb
PPTX
Инструменты тестирования, или хочешь сделать хорошо - сделай это сам
PPTX
How QA engineers could affect quality?
PPT
Джентельменский набор тест-лида
PPTX
Тестирование PhoneGap-приложений: специфика + опыт
PPTX
Полезные фишки тестировщика или о чем никогда не стоит забывать
QA Fest 2016. Александр Неделяев. Браузерные помощники тестировщика
QA Fes 2016. Алексей Виноградов. Page Objects: лучше проще, да лучшe
QA Fes 2016. Иван Пашко. Теория Дарвина в тестах. Эволюция Wait-ов.
QA Fest 2016. Андрей Мясников. Тест-дизайн для чайников
QA Fes 2016. Анастасия Асеева. Роль тестирования в Devops
QA Fest 2016. Алексей Виноградов. Цель тестирования. А на самом деле?
QA Fest 2016. Татьяна Люлюченко. Немного о мобильных браузерах
Сергей Семашко "End to end test: cheap and effective"
QA Fes 2016. Анна Карпенко. Специфика тестирования мобильных приложений или к...
QA Fest 2016. Денис Яременко. Как облегчить процесс мобильного тестирования
QA Fes 2016. Василий Сливка. 10 лучших практик для тестирования мобильных при...
QA Fes 2016. Катерина Овеченко & Михаил Дырда. История одной авантюры: наш не...
QA Fest 2016. Антон Серпутько. Автоматизация запуска тестов с помощью Jenkins...
QA Fes 2016. Игорь Любин. Об автоматическом тестировании бэкенда в MediaMarkt
Easy tests with Selenide and Easyb
Инструменты тестирования, или хочешь сделать хорошо - сделай это сам
How QA engineers could affect quality?
Джентельменский набор тест-лида
Тестирование PhoneGap-приложений: специфика + опыт
Полезные фишки тестировщика или о чем никогда не стоит забывать
Ad

Similar to QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для браузерной автоматизации (20)

PPTX
ProtractorJS for automated testing of Angular 1.x/2.x applications
PPTX
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
PDF
A Introduction to the World of Node, Javascript & Selenium
PDF
Moving from selenium to protractor for test automation
PPTX
Protractor framework architecture with example
PPTX
Protractor overview
PPTX
Protractor End To End Testing For AngularJS
PDF
Fullstack End-to-end test automation with Node.js, one year later
PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
PPTX
Protractor Tutorial Quality in Agile 2015
PPTX
Protractor survival guide
PDF
Node.js and Selenium Webdriver, a journey from the Java side
PDF
Workshop - E2e tests with protractor
PPTX
Protractor Testing Automation Tool Framework / Jasmine Reporters
PPTX
Presentation_Protractor
PPTX
Knowledge of web ui for automation testing
PPTX
Protractor training
PPTX
An Introduction to AngularJS End to End Testing using Protractor
PDF
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
PPTX
Introduction to Protractor - Habilelabs
ProtractorJS for automated testing of Angular 1.x/2.x applications
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
A Introduction to the World of Node, Javascript & Selenium
Moving from selenium to protractor for test automation
Protractor framework architecture with example
Protractor overview
Protractor End To End Testing For AngularJS
Fullstack End-to-end test automation with Node.js, one year later
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Protractor Tutorial Quality in Agile 2015
Protractor survival guide
Node.js and Selenium Webdriver, a journey from the Java side
Workshop - E2e tests with protractor
Protractor Testing Automation Tool Framework / Jasmine Reporters
Presentation_Protractor
Knowledge of web ui for automation testing
Protractor training
An Introduction to AngularJS End to End Testing using Protractor
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
Introduction to Protractor - Habilelabs

More from QAFest (20)

PDF
QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилин
PPTX
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The Future
PPTX
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...
PDF
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...
PDF
QA Fest 2019. Никита Галкин. Как зарабатывать больше
PDF
QA Fest 2019. Сергей Пирогов. Why everything is spoiled
PDF
QA Fest 2019. Сергей Новик. Между мотивацией и выгоранием
PPTX
QA Fest 2019. Владимир Никонов. Код Шредингера или зачем и как мы тестируем н...
PPTX
QA Fest 2019. Владимир Трандафилов. GUI automation of WEB application with SV...
PDF
QA Fest 2019. Иван Крутов. Bulletproof Selenium Cluster
PPTX
QA Fest 2019. Николай Мижигурский. Миссия /*не*/выполнима: гуманитарий собесе...
PDF
QA Fest 2019. Володимир Стиран. Чим раніше – тим вигідніше, але ніколи не піз...
PPTX
QA Fest 2019. Дмитрий Прокопук. Mocks and network tricks in UI automation
PDF
QA Fest 2019. Екатерина Дядечко. Тестирование медицинского софта — вызовы и в...
PDF
QA Fest 2019. Катерина Черникова. Tune your P’s: the pop-art of keeping testa...
PDF
QA Fest 2019. Алиса Бойко. Какнезапутаться в коммуникативных сетях IT
PPTX
QA Fest 2019. Святослав Логин. Как найти уязвимости в мобильном приложении
PPTX
QA Fest 2019. Катерина Шепелєва та Інна Оснач. Що українцям потрібно знати пр...
PDF
QA Fest 2019. Антон Серпутько. Нагрузочное тестирование распределенных асинхр...
PPTX
QA Fest 2019. Петр Тарасенко. QA Hackathon - The Cookbook 22
QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилин
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The Future
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...
QA Fest 2019. Никита Галкин. Как зарабатывать больше
QA Fest 2019. Сергей Пирогов. Why everything is spoiled
QA Fest 2019. Сергей Новик. Между мотивацией и выгоранием
QA Fest 2019. Владимир Никонов. Код Шредингера или зачем и как мы тестируем н...
QA Fest 2019. Владимир Трандафилов. GUI automation of WEB application with SV...
QA Fest 2019. Иван Крутов. Bulletproof Selenium Cluster
QA Fest 2019. Николай Мижигурский. Миссия /*не*/выполнима: гуманитарий собесе...
QA Fest 2019. Володимир Стиран. Чим раніше – тим вигідніше, але ніколи не піз...
QA Fest 2019. Дмитрий Прокопук. Mocks and network tricks in UI automation
QA Fest 2019. Екатерина Дядечко. Тестирование медицинского софта — вызовы и в...
QA Fest 2019. Катерина Черникова. Tune your P’s: the pop-art of keeping testa...
QA Fest 2019. Алиса Бойко. Какнезапутаться в коммуникативных сетях IT
QA Fest 2019. Святослав Логин. Как найти уязвимости в мобильном приложении
QA Fest 2019. Катерина Шепелєва та Інна Оснач. Що українцям потрібно знати пр...
QA Fest 2019. Антон Серпутько. Нагрузочное тестирование распределенных асинхр...
QA Fest 2019. Петр Тарасенко. QA Hackathon - The Cookbook 22

Recently uploaded (20)

PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Cell Types and Its function , kingdom of life
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Complications of Minimal Access Surgery at WLH
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Business Ethics Teaching Materials for college
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
01-Introduction-to-Information-Management.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Cell Types and Its function , kingdom of life
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
FourierSeries-QuestionsWithAnswers(Part-A).pdf
RMMM.pdf make it easy to upload and study
Complications of Minimal Access Surgery at WLH
STATICS OF THE RIGID BODIES Hibbelers.pdf
Anesthesia in Laparoscopic Surgery in India
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Business Ethics Teaching Materials for college
Microbial diseases, their pathogenesis and prophylaxis
VCE English Exam - Section C Student Revision Booklet
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
01-Introduction-to-Information-Management.pdf

QA Fes 2016. Александр Хотемской. Обзор ProtractorJS как фреймворка для браузерной автоматизации

  • 1. Selenium WebDriverJS based framework for automated testing of Angular 1.x/2.x applications OLEKSANDR KHOTEMSKYI xotabu4.github.io
  • 2.  Julie Ralph(Google) is one of the main contributors, made first commits in January 2013  Created as an answer to question: ”How to make end to end tests for AngularJS applications easier?”  Now ProtractorJS reached version 4.x, with over 1300 commits, 5700 GitHub stars, 200 contributors
  • 4.  JS is one of the most popular languages today, and TypeScript is as primary in Angular 2.0 https://dou.ua/lenta/articles/language-rating-jan-2016/ JAVA C# JavaScript PHP PythonC++ Ruby
  • 5.  Easier than Java  Thousands of libraries already exist for JS/NodeJS. Friendly community, tons of open source code. Package manager already included in NodeJS  Much easier common code like JSON parsing, sending HTTP requests, and others  Duck-typing, monkey-patching  Tools are smaller, and project start is faster  Newest versions of TypeScript or ECMAScript 6 makes code much easier to write and understand  Same language for front-end, back-end and tests means that same code execution environment
  • 6.  Developed by Microsoft team  Superset of JavaScript (includes JavaScript)  Compiles to JavaScript (ECMAScript 3, 5 or 6)  Optional types! This allows to have autocomplete in IDE  Easier refactoring of code  Has features that not yet in JavaScript specification (@Annotations, async/await)  Compilation errors, instead of runtime errors in JavaScript
  • 7. ProtractorJS Java Selenium WebDriver High-level framework Low-level automation library (not framework) Uses script languages: TypeScript or JavaScript or both same time Uses Java JasimineJS (test runner and assertions), SauceLabs/BrowserStack integration, basic reporting, interactive debugger, command line parameters, configuration files  Node Package Manager shows ~628 results for ‘protractor’ Maven shows ~422 results for ‘selenium webdriver’ Asynchronous, uses own control-flow, and Promises objects Synchronous, traditional approach Ability to run tests in parallel Parallel running should be done with additional libraries/frameworks PageObjects are just objects with attributes and functions PageObjects require @FindBy annotations and PageObjectFactory usage. Plugins. Extra element locators. Mobile browsers support (with Appium). Mobile browsers support.
  • 8. Test Runner (JasmineJS, Cucumber …) ProtractorJS Selenium JavaScript official bindings NodeJS environment Test Runner extensions Selenium Standalone Server (JAVA) Other JS modules HTTP JSON ChromeDriver GeckoDriver EdgeDriver SafariDriver Other drivers
  • 9. • Runs on NodeJS 4.x, 5.x, 6.x • Can be used with different Test Runners (JasmineJS, CucumberJS, Mocha, others) • Can connect to browser using WebDriver server or directly (Chrome and Firefox only) • Supports all browsers that WebDriver does: Chrome, Firefox, Edge, Safari, Opera, PhantomJS and mobile • Angular 1.x and Angular 2.x ready!
  • 10. One of the key features of ProtractorJS that it is uses same JSON WebDriver Wire protocol as other language bindings. This code will be executed as 3 separate JSON WebDriver Wire Protocol commands: Synchronizing with AngularJS application Locating element on the page Sending ‘click’ action for element
  • 11. • Protractor uses ‘Wrapper’ pattern to add own features to standard WebDriver, WebElement, Locators objects Browser(WebDriver instance) + Inherited from WebDriver • getProcessedConfig • forkNewDriverInstance • restart • useAllAngular2AppRoots • waitForAngular • findElement • findElements • isElementPresent • addMockModule • clearMockModules • removeMockModule • getRegisteredMockModules • get • refresh • navigate • setLocation • getLocationAbsUrl • debugger • enterRepl • pause • wrapDriver actions touchActions executeScript executeAsyncScri pt call wait sleep getPageSource close getCurrentUrl getTitle takeScreenshot switchTo
  • 12. ElementFinder + Inherited from WebElement• then • clone • locator • getWebElement • all • element • $$ • $ • isPresent • isElementPresent • evaluate • allowAnimations • equals • getDriver • getId • getRawId • serialize • findElement • click • sendKeys • getTagName • getCssValue • getAttribute • getText • getSize • getLocation • isEnabled • isSelected • submit • clear • isDisplayed • takeScreenshot
  • 13. Protractor Locators + Inherited from WebDriver Locators• addLocator • binding • exactBinding • model • buttonText • partialButtonText • repeater • exactRepeater • cssContainingText • options • deepCss • className • css • id • linkText • js • name • partialLinkText • tagName • xpath
  • 15.  JavaScript is single threaded (mostly)  To have possibility to do multiple tasks at once – JavaScript run them all in single thread, and quickly switch between them  Async tasks are running in isolation. To make execution step by step – callbacks are used  Callbacks are just functions, that will be called when async function is finished. It is like – “call this when you are done”. You can pass any arguments to them
  • 18.  Pattern to avoid callback hell, extension of callbacks  Almost every function from API returns special object – Promise  Promise is a object, that will be resolved to a value (any), or rejected if value can’t be returned
  • 19.  Do not try to write in synchronous manner! You should think differently when writing async code  When you asserting results – promises automatically resolved. Do not worry to resolve promise before assertion  To wait something on the page – use browser.wait() or browser.sleep()  ES7 features are on their way! async/await will make our life much easier  Be brave and good luck
  • 21. https://gist.github.com/Xotabu4/f26afb9e24397c9d059bb984d30a6b0a Example of simple test case JAVA + Pure Selenium JAVA + JUNIT TypeScript + ProtractorJS + JasmineJS https://gist.github.com/Xotabu4/dcfe83bc98ad304f58f3b05de9cd6c69
  • 22. https://gist.github.com/Xotabu4/79ece1d104f2557a70cd079b62f46f45 Example of simple pageObject pattern usage JAVA + Selenium PageObjectFactory (@FindBy) TypeScript + ProtractorJS https://gist.github.com/Xotabu4/a9334f22933d1d6a16c820ccb4bd6635
  • 23. And useful links:  Protractor site: http://www.protractortest.org  Promises, WebDriver Control Flow documentation: http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/promise.html  Gitter chat: https://gitter.im/angular/protractor  StackOverflow(top questions): http://stackoverflow.com/questions/tagged/protractor?sort=votes&pageSize=20  GitHub: https://github.com/angular/protractor  TypeScript documentation: https://www.typescriptlang.org/docs/tutorial.html  ES6 features: http://es6-features.org/  Protractor TypeScript example: https://github.com/angular/protractor/tree/master/exampleTypescript OLEKSANDR KHOTEMSKYI xotabu4.github.io 2016

Editor's Notes

  • #3: Последняя 4.4
  • #7: Мое мнение – для новых проектов использовать уже TypeScript, старые можно частично мигрировать на TypeScript, или оставить как есть. ПОКАЖИ ВИДЕО!!!
  • #9: Здесь важно сказать что протрактор работает по точно такому же протоколу как и Java bindings. То есть в браузере разницы видно не будет. + javascript бингинги официальные, и поддерживаются практически наравне с джавашными и остальными. WebDriver wire protocol
  • #11: Here is exampe of simple Protractor interaction with the page: First, Protractor tells the browser to run a snippet of JavaScript. This is a custom command which asks Angular to respond when the application is done with all timeouts and asynchronous requests, and ready for the test to resume. Then, the command to find the element is sent. Finally the command to perform a click action is sent. Summary: Protractor uses the same API to manipulate browser as any other language bindings, so browser won’t notice any difference here
  • #12: Protractor element EXTENDS WebDriverJS element, so all functions are accessible.
  • #13: Protractor element EXTENDS WebDriverJS element, so all functions are accessible.
  • #14: ProtractorBy.prototype.deepCss - Find an element by css selector within the Shadow DOM. ProtractorBy.prototype.options - Find an element by ng-options expression.
  • #15: Тут рассказать про асинхронность и контрол флоу Больше всего у людей которые начинают переходить в мир JS взрывает мозг именно асинхронность. Попытаемся рассказать основные моменты
  • #19: Это вернет Promise, который станет или текущим именем пользователя, или пустой строкой, в случае если такого элемента не существует.
  • #22: Explicit creating and closing of browser is needed
  • #23: Explicit creating and closing of browser is needed