SlideShare a Scribd company logo
webdriver.io
whoami
Giovanni Lela
CTO @ linkme srl
Main background Node.js backend developer
What I needed
- Test as the user would do - 100% dumb
blackbox tests of the web interface - basically
user stories acceptance
- As easy to use as it gets
Secondary objectives
Have an easy to learn language so that QA and non hardcore javascript people can use it
Do more than just browser automation - also prepare the database, trigger websocket events,
prompt for passwords
Can run tests on multiple OS/Browser versions and combinations
Compatible with mocha / chai
Compatible with existing automation scripts (grunt, gulp, whatever)
Enter webdriver.io
var assert = require('assert'); //OR chai or whatever
describe('webdriver.io page', function() {
it('should have the right title', function () {
browser.url('http://webdriver.io');
var title = browser.getTitle();
assert.equal(title, 'WebdriverIO - Selenium 2.0 javascript bindings for nodejs');
});
});
1- javascript - node.js
2- mocha
3- a browser object - where does it come from?
4- synchronous code
Is this what i need? Testing like a user
Yes, it just automates an actual browser with selenium (we’ll get to it)
● we emulate user interaction on the browser and then read the result strait out of the dom
● it as an actual browser not the damn phantomjs (which can still be used)
○ Flexbox compatibility
○ Some configuration / installation issues
Ease of use
1- javascript synchronous commands - ok cool no need for performance here
2- lots of selector strategies :
● Css query selector style - browser.click('h2.subheading a');
● Visible text matching - browser.click('*=I’M A LINK!')
● XPath :/
● Mobile selectors - yes you heard right
Ease of use - wdio test runner
npm i -g wdio selenium-standalone
● wdio config sets up thw whole thing for you letting you choose:
○ local test / cloud test (saucelabs, browserstack)
○ test runner (mocha / jasmine / cucumber) - also installas the connector for you
○ test reporter
○ .. and so on
● selenium standalone install and selenium standalone start
● write your tests
● wdio <config file>
You can also use it as standalone
var webdriverio = require('webdriverio');
var options = {..};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end();
It also has plugins for grunt / gulp
Custom commands
Unfortunately we cannot add async commands directly in the test but we can define custom commands.
browser.addCommand('getOneTimePassword', function async(){
return new Promise((resolve, reject)=>{
rl.question('Your one time password?', (test) => {
resolve(test)
rl.close()
})
})
})
---
const myPass = browser.getOneTimePassword()
browser.setValue('input[name="otp"]', stuff)
how does this work?
● The testing script
● The selenium webdriver server
● The browser
The communication to web driver follows
the webdriver protocol
https://w3c.github.io/webdriver/webdriver-spec.html
test script
webdriver
browser / mobile
app
selenium WebDriver protocol
POST /wd/hub/session/e1252817-b577-4f21-8041-570fbc727f62/url HTTP/1.1
Connection: keep-alive
[...]
host: 127.0.0.1:4444
{"url":"http://webdriver.io"}
HTTP/1.1 200 OK
Date: Sun, 29 May 2016 21:19:53 GMT
Content-Type: application/json; charset=utf-8
{"state":"success","sessionId":"e1252817-b577-4f21-8041-570fbc727f62","hCode":836948231,"value":
null,"class":"org.openqa.selenium.remote.Response","status":0}
Cool stuff I did not know about
CSS regression settings
● Define areas within your application that should always look the same
● Use WebdriverIO and WebdriverCSS to write some E2E tests and take screenshots of these areas
● Continue working on your application or website
● After a while rerun the tests
● If desired areas differ from previous taken screenshots an image diff gets generated and you get
notified in your tests
CSS Regression testing
client
.init()
.url('http://example.com')
.webdrivercss('startpage',[
{
name: 'header',
elem: '#header'
}, {
name: 'hero',
elem: '//*[@id="hero"]/div[2]'
}
], function(err, res) {
assert.ifError(err);
assert.ok(res.header[0].isWithinMisMatchTolerance);
assert.ok(res.hero[0].isWithinMisMatchTolerance);
})
.end();
Other cool stuff
● Page object support
● Sauce labs support
● Mobile / Appium support
var selector = 'new UiSelector().text("Cancel")).className("android.widget.Button")';
browser.click(selector);
client.rotate(114, 198, 5, 3, 220, 2);
Uncool things I did not know about
● Keeping selenium and the chrome driver up to date is not funny, also you will need java to run it
● Not all browsers are created equal, so are their drivers
● Webdriver css is not compatibile with recent releases of webdriver.io
● For single page application you end up writing a lot of stuff like this
browser.waitForExist('div.btn-primary-color-full.btn-large') browser.click
('div.btn-primary-color-full.btn-large')
Next steps
● Wait for webdriver css to get on par with the current wdio release
● Selenium ide - translate from selenese
<table>
<tr><td>open</td><td></td><td>/download/</td></tr>
<tr><td>assertTitle</td><td></td><td>Downloads</td></tr>
<tr><td>verifyText</td><td>//h2</td><td>Downloads</td></tr>
</table>

More Related Content

PDF
Webdriver io presentation
PPTX
A guide to getting started with WebdriverIO
PPTX
WebdriverIO: the Swiss Army Knife of testing
PPTX
Automation Testing by Selenium Web Driver
PPTX
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
PPT
Selenium
PDF
Introduction to Selenium Automation
PPTX
Selenium WebDriver
Webdriver io presentation
A guide to getting started with WebdriverIO
WebdriverIO: the Swiss Army Knife of testing
Automation Testing by Selenium Web Driver
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium
Introduction to Selenium Automation
Selenium WebDriver

What's hot (20)

PPTX
Introduction to Selenium Web Driver
PPTX
BDD with CucumberJS and WebdriverIO
PDF
What's new in selenium 4
PPTX
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
PDF
Selenium with Cucumber
PPTX
An overview of selenium webdriver
PPTX
Test automation using selenium
PPTX
Test Automation Framework with BDD and Cucumber
PPTX
Selenium
PPTX
Spring Security 5
PPTX
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
PPTX
Rest assured
PPTX
Selenium introduction
PPT
Selenium Concepts
PPTX
QA Challenge Accepted 4.0 - Cypress vs. Selenium
PDF
진민완 포트폴리오
PDF
Cross Browser Testing Using LambdaTest | Edureka
PPTX
Introduction to spring boot
PPTX
Selenium locators: ID, Name, xpath, CSS Selector advance methods
PPTX
Selenium WebDriver training
Introduction to Selenium Web Driver
BDD with CucumberJS and WebdriverIO
What's new in selenium 4
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium with Cucumber
An overview of selenium webdriver
Test automation using selenium
Test Automation Framework with BDD and Cucumber
Selenium
Spring Security 5
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
Rest assured
Selenium introduction
Selenium Concepts
QA Challenge Accepted 4.0 - Cypress vs. Selenium
진민완 포트폴리오
Cross Browser Testing Using LambdaTest | Edureka
Introduction to spring boot
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Selenium WebDriver training
Ad

Viewers also liked (16)

PDF
One step in the future: CSS variables
PDF
Design Patterns for Scalable Test Automation With Selenium & WebdriverIO
PDF
Webdriver cheatsheets summary
PPTX
SeConf2015: Advanced Automated Visual Testing With Selenium
PPT
Android & iOS Automation Using Appium
PDF
codecept.js introduce - front end test E2E tool introduce
PDF
Selenium Basics Tutorial
PDF
Selenium Tips & Tricks
PPT
Object Oriented Programming with Java
PPT
Web Test Automation with Selenium
PPT
Java Basics for selenium
PDF
Automation Testing using Selenium
PPT
Selenium ppt
PDF
Appium: Prime Cuts
PDF
Automated Web Testing using JavaScript
PDF
Join the darkside: Selenium testing with Nightwatch.js
One step in the future: CSS variables
Design Patterns for Scalable Test Automation With Selenium & WebdriverIO
Webdriver cheatsheets summary
SeConf2015: Advanced Automated Visual Testing With Selenium
Android & iOS Automation Using Appium
codecept.js introduce - front end test E2E tool introduce
Selenium Basics Tutorial
Selenium Tips & Tricks
Object Oriented Programming with Java
Web Test Automation with Selenium
Java Basics for selenium
Automation Testing using Selenium
Selenium ppt
Appium: Prime Cuts
Automated Web Testing using JavaScript
Join the darkside: Selenium testing with Nightwatch.js
Ad

Similar to Webdriver.io (20)

PDF
WebDriverIO Tutorial for Selenium Automation.pdf
PPTX
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
PDF
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
PPTX
Argentesting 2017 - Workshop Webdriver.io
PDF
Web driver selenium simplified
PDF
Handson Selenium Webdriver With Java A Deep Dive Into The Development Of Endt...
PDF
Fullstack End-to-end test automation with Node.js, one year later
PPTX
Selenium.pptx
PDF
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
PDF
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
PPTX
Selenium presentation
PPTX
A Deep Dive into the W3C WebDriver Specification
PDF
Selenium for Tester.pdf
PPTX
Selenium topic 3 -Web Driver Basics
PPTX
Introduction to the Selenium_Session1.pptx
PPTX
Selenium.pptx
PDF
How To Use Selenium Successfully
PPTX
Selenium Training in Chennai Demo Part-2
PDF
Node.js and Selenium Webdriver, a journey from the Java side
WebDriverIO Tutorial for Selenium Automation.pdf
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
Argentesting 2017 - Workshop Webdriver.io
Web driver selenium simplified
Handson Selenium Webdriver With Java A Deep Dive Into The Development Of Endt...
Fullstack End-to-end test automation with Node.js, one year later
Selenium.pptx
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium presentation
A Deep Dive into the W3C WebDriver Specification
Selenium for Tester.pdf
Selenium topic 3 -Web Driver Basics
Introduction to the Selenium_Session1.pptx
Selenium.pptx
How To Use Selenium Successfully
Selenium Training in Chennai Demo Part-2
Node.js and Selenium Webdriver, a journey from the Java side

More from LinkMe Srl (8)

PDF
Adventures in docker compose
PDF
Corso su ReactJS
PDF
A React Journey
PDF
Angular Intermediate
PDF
NodeJS
PDF
Angular js quickstart
PDF
M&M - MeanMilan @CodeMotionMilan
PPTX
Presentazione Codemotion
Adventures in docker compose
Corso su ReactJS
A React Journey
Angular Intermediate
NodeJS
Angular js quickstart
M&M - MeanMilan @CodeMotionMilan
Presentazione Codemotion

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation_ Review paper, used for researhc scholars
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25 Week I
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation theory and applications.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Machine learning based COVID-19 study performance prediction
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Programs and apps: productivity, graphics, security and other tools
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Reach Out and Touch Someone: Haptics and Empathic Computing
Diabetes mellitus diagnosis method based random forest with bat algorithm
Network Security Unit 5.pdf for BCA BBA.
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars

Webdriver.io

  • 2. whoami Giovanni Lela CTO @ linkme srl Main background Node.js backend developer
  • 3. What I needed - Test as the user would do - 100% dumb blackbox tests of the web interface - basically user stories acceptance - As easy to use as it gets
  • 4. Secondary objectives Have an easy to learn language so that QA and non hardcore javascript people can use it Do more than just browser automation - also prepare the database, trigger websocket events, prompt for passwords Can run tests on multiple OS/Browser versions and combinations Compatible with mocha / chai Compatible with existing automation scripts (grunt, gulp, whatever)
  • 5. Enter webdriver.io var assert = require('assert'); //OR chai or whatever describe('webdriver.io page', function() { it('should have the right title', function () { browser.url('http://webdriver.io'); var title = browser.getTitle(); assert.equal(title, 'WebdriverIO - Selenium 2.0 javascript bindings for nodejs'); }); }); 1- javascript - node.js 2- mocha 3- a browser object - where does it come from? 4- synchronous code
  • 6. Is this what i need? Testing like a user Yes, it just automates an actual browser with selenium (we’ll get to it) ● we emulate user interaction on the browser and then read the result strait out of the dom ● it as an actual browser not the damn phantomjs (which can still be used) ○ Flexbox compatibility ○ Some configuration / installation issues
  • 7. Ease of use 1- javascript synchronous commands - ok cool no need for performance here 2- lots of selector strategies : ● Css query selector style - browser.click('h2.subheading a'); ● Visible text matching - browser.click('*=I’M A LINK!') ● XPath :/ ● Mobile selectors - yes you heard right
  • 8. Ease of use - wdio test runner npm i -g wdio selenium-standalone ● wdio config sets up thw whole thing for you letting you choose: ○ local test / cloud test (saucelabs, browserstack) ○ test runner (mocha / jasmine / cucumber) - also installas the connector for you ○ test reporter ○ .. and so on ● selenium standalone install and selenium standalone start ● write your tests ● wdio <config file>
  • 9. You can also use it as standalone var webdriverio = require('webdriverio'); var options = {..}; webdriverio .remote(options) .init() .url('http://www.google.com') .getTitle().then(function(title) { console.log('Title was: ' + title); }) .end(); It also has plugins for grunt / gulp
  • 10. Custom commands Unfortunately we cannot add async commands directly in the test but we can define custom commands. browser.addCommand('getOneTimePassword', function async(){ return new Promise((resolve, reject)=>{ rl.question('Your one time password?', (test) => { resolve(test) rl.close() }) }) }) --- const myPass = browser.getOneTimePassword() browser.setValue('input[name="otp"]', stuff)
  • 11. how does this work? ● The testing script ● The selenium webdriver server ● The browser The communication to web driver follows the webdriver protocol https://w3c.github.io/webdriver/webdriver-spec.html test script webdriver browser / mobile app
  • 12. selenium WebDriver protocol POST /wd/hub/session/e1252817-b577-4f21-8041-570fbc727f62/url HTTP/1.1 Connection: keep-alive [...] host: 127.0.0.1:4444 {"url":"http://webdriver.io"} HTTP/1.1 200 OK Date: Sun, 29 May 2016 21:19:53 GMT Content-Type: application/json; charset=utf-8 {"state":"success","sessionId":"e1252817-b577-4f21-8041-570fbc727f62","hCode":836948231,"value": null,"class":"org.openqa.selenium.remote.Response","status":0}
  • 13. Cool stuff I did not know about CSS regression settings ● Define areas within your application that should always look the same ● Use WebdriverIO and WebdriverCSS to write some E2E tests and take screenshots of these areas ● Continue working on your application or website ● After a while rerun the tests ● If desired areas differ from previous taken screenshots an image diff gets generated and you get notified in your tests
  • 14. CSS Regression testing client .init() .url('http://example.com') .webdrivercss('startpage',[ { name: 'header', elem: '#header' }, { name: 'hero', elem: '//*[@id="hero"]/div[2]' } ], function(err, res) { assert.ifError(err); assert.ok(res.header[0].isWithinMisMatchTolerance); assert.ok(res.hero[0].isWithinMisMatchTolerance); }) .end();
  • 15. Other cool stuff ● Page object support ● Sauce labs support ● Mobile / Appium support var selector = 'new UiSelector().text("Cancel")).className("android.widget.Button")'; browser.click(selector); client.rotate(114, 198, 5, 3, 220, 2);
  • 16. Uncool things I did not know about ● Keeping selenium and the chrome driver up to date is not funny, also you will need java to run it ● Not all browsers are created equal, so are their drivers ● Webdriver css is not compatibile with recent releases of webdriver.io ● For single page application you end up writing a lot of stuff like this browser.waitForExist('div.btn-primary-color-full.btn-large') browser.click ('div.btn-primary-color-full.btn-large')
  • 17. Next steps ● Wait for webdriver css to get on par with the current wdio release ● Selenium ide - translate from selenese <table> <tr><td>open</td><td></td><td>/download/</td></tr> <tr><td>assertTitle</td><td></td><td>Downloads</td></tr> <tr><td>verifyText</td><td>//h2</td><td>Downloads</td></tr> </table>