SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Copyright © 2015 spriteCloud B.V. All rights reserved.
Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation
Copyright © 2015 spriteCloud B.V. All rights reserved.
Getting started:
This presentation will take you through the steps needed to set up a test automation
project using Cucumber - a software tool that runs automated tests in the BBD style -
in combination with Lapis Lazuli, a gem that provides Cucumber helper functions and
scaffolding for easier web test automation suite development.
To do this you will need to have installed Ruby with some drivers and libraries. You
can find detailed notes on how to do this here:
http://www.testautomation.info/Getting_Started
Copyright © 2015 spriteCloud B.V. All rights reserved.
What you need:
To successfully follow this tutorial, prior
knowledge of test automation isn’t needed, but
knowledge of scripting - especially Ruby - and
HTML skills are recommended.
Copyright © 2015 spriteCloud B.V. All rights reserved.
You will find out about:
- Gherkin
- Cucumber
- Browser testing
- Creating a TA project
- Best practices
Copyright © 2015 spriteCloud B.V. All rights reserved.
Example website
To set up this project, we will test on a
small web application as an example.
Try the following steps out at:
http://www.testautomation.info/training-page/
Note:
The web app doesn’t store information,
closing the browser window will reset the page
and created user accounts.
Copyright © 2015 spriteCloud B.V. All rights reserved.
HTML introduction
Firstly, this is HTML Structure you will
need to refer to:
<parent>
<element>
<child></child>
<child></child>
</element>
<element/>
</parent>
HTML Element:
<a id="homepage"
href="http://www.spritecloud.com">
spriteCloud
</a>
Element (node)
Attribute (node) name
Attribute (node) value
Text (node)
Copyright © 2015 spriteCloud B.V. All rights reserved.
Code examples
A very short explanation of code you
need during this training:
A variable is a label you can give to a
piece of data. Data can be simple
(numbers, text, functions) or
complex. Complex data or objects
contain variables.
Functions return data based on
certain input data.
# This is a comment
variable = "string"
variable2 = :symbol
variable3 = 1000 * 3 + 200
Object.variable
puts("Hello World!")
=> "Hello World!"
$ program "on commandline"
# Red is used as a highlight
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
Install Lapis Lazuli with:
$ gem install lapis_lazuli
Run the Interactive Ruby Shell
$ irb
# Load the library
require("lapis_lazuli")
# Activate LL in this IRB session
include(LapisLazuli)
# Goto the website
browser.goto("http://www.testautomatio
n.info/training-page/")
# Print the page title
browser.title()
=> "Calliope Training"
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
Finding elements on page using LL
uses the .find / .find_all function.
It allows you to do complex searches,
but today we will focus on the basics.
# Find the title
# using the unique ID attribute
browser.find("title").text()
# or the longer syntax
browser.find({:id => "title"})
# Number of links on a page
# using the element
browser.find_all(:a).length()
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
Sometimes elements don’t have an
ID and you will have to use other
attributes.
# Number text fields on the page
# using attributes
browser.find_all({:like => {
:element => "input",
:attribute => "type",
:include => "text"}}
).length()
# or a short notation
browser.find_all({
:like => ["input","type","text"]
})
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
Website automation requires more
interaction than loading pages and
finding elements.
Start by clicking the login button
# Find the login button
# and save it in a variable
login = browser.find({
:id => "button-login"
})
# Correct button?
login.flash()
# Click the button
login.click()
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
To do a successful login we need to
enter our credentials:
# Username text field
username = browser.find({
:id => "login-username"
})
# Enter the username
username.send_keys("test")
# Repeat with password field
# Do the login
login.click()
Username test
Password test
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
What happens if you try to find an
element that doesn’t exist on the
page?
# Search for not existing element
browser.find({:id => "HIDDEN"})
=> RuntimeError: Error in find -
Cannot find elements with
selectors: {:pick=>:first,
:mode=>:match_one,
:selectors=>[{:element=>"HIDDEN"}]}
(http://www.spritecloud.com/)
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
The find functions allow you to set
your own custom error message to
helps non-technical users understand
the issue.
# Search for not existing element
browser.find({
:id => “HIDDEN”,
:message => “Could not find
hidden element”
})
=> RuntimeError: Could not find
hidden element - Cannot find
elements with selectors: { … }
(http://www.spritecloud.com/)
Copyright © 2015 spriteCloud B.V. All rights reserved.
Browser testing
Now try it yourself:
- Click the first todo item
- Add a todo
Or try out automating another website, like searching on Google.com
Copyright © 2015 spriteCloud B.V. All rights reserved.
Technology framework
- BDD Language to describe tests
- Test specification and execution
- Tools to improve Watir for cucumber testing
- Tools to improve WebDriver
- Browser automation
- Programming Language
- Cucumber Software-as-a-Service by spriteCloud
Lapis Lazuli
Watir
Selenium WebDriver
Ruby
Cucumber
Gherkin
Calliope
Copyright © 2015 spriteCloud B.V. All rights reserved.
Gherkin
Gherkin is the language that
Cucumber understands. It is a
Business Readable, Domain
Specific Language that lets you
describe software's behaviour without
detailing how that behaviour is
implemented. Gherkin serves two
purposes — documentation and
automated tests.
Feature: Some terse yet descriptive
text of what is desired
Scenario: Some situation
Given some precondition
And some other precondition
When some action by the actor
And some other action
And yet another action
Then some outcome is achieved
And something else we can check
Copyright © 2015 spriteCloud B.V. All rights reserved.
Gherkin
For the feature description, a three-
line user story is ideal:
● In order to <achieve goal>
● As a <role>
● I want to <activity details>
Feature: Todo Clicking
In order to complete a todo
As a test automation novice
I want to click a todo
Scenario: Regular numbers
Given I am logged in
When I click the fist todo
Then 2 todos remain
Copyright © 2015 spriteCloud B.V. All rights reserved.
Cucumber
Cucumber is a software tool that
computer programmers use for
testing other software. It runs
automated acceptance tests written
in a behavior-driven development
(BDD) style.
Given /I am logged in/ do
browser.goto
"http://www.testautomation.info/training-page/"
end
When /I click the first todo/ do
browser.find("todo-item-0").click
end
Then /(d+) todos remain/ do
|number|
browser.find("todo-remaining")
# … some extra code
end
Copyright © 2015 spriteCloud B.V. All rights reserved.
Cucumber
Given /I am logged in/ do
browser.goto
"http://www.testautomation.info/training-page/"
end
When /I click the first todo/ do
browser.find("todo-item-0").click
end
Then /(d+) todos remain/ do
|number|
browser.find("todo-remaining")
end
Feature: Todo Clicking
In order to complete a todo
As a test automation novice
I want to click a todo
Scenario: Regular numbers
Given I am logged in
When I click the fist todo
Then 2 todos remain
Copyright © 2015 spriteCloud B.V. All rights reserved.
Starting a new project
To create a project type:
$ lapis_lazuli create MyTaTraining
The project already includes an
example scenario, so lets run it:
$ cd MyTaTraining/
$ cucumber
MyTaTraining/
config/
config.yml
cucumber.yml
features/
example.feature
step_definitions/
interaction_steps.rb
validation_steps.rb
support/
env.rb
Copyright © 2015 spriteCloud B.V. All rights reserved.
Cucumber result
Let’s look at the cucumber output:
Scenario: example01 - Google Search # example.feature:8
Given I navigate to Google in english # interaction_steps.rb:6
And I search for "spriteCloud" # interaction_steps.rb:16
Then I see "www.spriteCloud.com" on the page # validation_steps.rb:6
1 scenario (1 passed)
3 steps (3 passed)
0m9.976s
Copyright © 2015 spriteCloud B.V. All rights reserved.
Cucumber result
Let’s look at the cucumber output:
Scenario: example01 - Google Search
#example.feature:8
Given I navigate to Google in english
# interaction_steps.rb:6
And I search for "spriteCloud"
# interaction_steps.rb:16
Then I see "www.spriteCloud.com" on the page
# validation_steps.rb:6
1 scenario (1 passed)
3 steps (3 passed)
0m9.976s
MyTaTraining/
config/
config.yml
cucumber.yml
features/
example.feature
step_definitions/
interaction_steps.rb
validation_steps.rb
support/
env.rb
Copyright © 2015 spriteCloud B.V. All rights reserved.
Cucumber options
By default Cucumber will run all
feature files it can find, but it has
multiple options for customized runs
Advanced:
To view all options
$ cucumber --help
# Using feature file
$ cucumber features/test.feature
# With line number
$ cucumber features/test.feature:10
# Run a single tag
$ cucumber --tags @example
# Run two tags (logical OR)
$ cucumber -t @example,@dev
# Run scenario with both tags (AND)
$ cucumber -t @example -t @dev
# Excluding a tag
$ cucumber -t ~@dev
# Check which scenarios will run
$ cucumber --dry-run
Copyright © 2015 spriteCloud B.V. All rights reserved.
TA Best practices
1. Don’t add ‘code’ to Gherkin
2. Validate if a step has been completed
3. Try to use XPath or the like and not RegExp
4. Don’t use hard timeouts
5. Work with the development team
6. Use shortest possible selector
7. Scenarios are independent
8. Keep your code clean and simple

Weitere ähnliche Inhalte

Was ist angesagt?

SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFesttomdale
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberTechWell
 
A tech writer, a map, and an app
A tech writer, a map, and an appA tech writer, a map, and an app
A tech writer, a map, and an appSarah Maddox
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetupscottw
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueMike North
 
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017Matt Raible
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011dimakovalenko
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behatimoneytech
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react formYao Nien Chung
 
How to create OpenSocial Apps in 45 minutes
How to create OpenSocial Apps in 45 minutesHow to create OpenSocial Apps in 45 minutes
How to create OpenSocial Apps in 45 minutesBastian Hofmann
 
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG🎤 Hanno Embregts 🎸
 
Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019Matt Raible
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...Ho Chi Minh City Software Testing Club
 
Intro to jQuery - LUGOR - Part 1
Intro to jQuery - LUGOR - Part 1Intro to jQuery - LUGOR - Part 1
Intro to jQuery - LUGOR - Part 1Ralph Whitbeck
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax componentsIgnacio Coloma
 
Bootiful Development with Spring Boot and Angular - Spring I/O 2017
Bootiful Development with Spring Boot and Angular - Spring I/O 2017Bootiful Development with Spring Boot and Angular - Spring I/O 2017
Bootiful Development with Spring Boot and Angular - Spring I/O 2017Matt Raible
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingDougal Campbell
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Matt Raible
 

Was ist angesagt? (20)

BDD with cucumber
BDD with cucumberBDD with cucumber
BDD with cucumber
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using Cucumber
 
A tech writer, a map, and an app
A tech writer, a map, and an appA tech writer, a map, and an app
A tech writer, a map, and an app
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetup
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js Glue
 
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
How to create OpenSocial Apps in 45 minutes
How to create OpenSocial Apps in 45 minutesHow to create OpenSocial Apps in 45 minutes
How to create OpenSocial Apps in 45 minutes
 
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
 
Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019Front End Development for Back End Java Developers - NYJavaSIG 2019
Front End Development for Back End Java Developers - NYJavaSIG 2019
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
 
Intro to jQuery - LUGOR - Part 1
Intro to jQuery - LUGOR - Part 1Intro to jQuery - LUGOR - Part 1
Intro to jQuery - LUGOR - Part 1
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
Bootiful Development with Spring Boot and Angular - Spring I/O 2017
Bootiful Development with Spring Boot and Angular - Spring I/O 2017Bootiful Development with Spring Boot and Angular - Spring I/O 2017
Bootiful Development with Spring Boot and Angular - Spring I/O 2017
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 

Ähnlich wie Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli

Software Testing
Software TestingSoftware Testing
Software Testingsuperphly
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Bitbar
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyondmguillem
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web ComponentsRed Pill Now
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experimentslacyrhoades
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemAlex Mikitenko
 
Automatisation in development and testing - within budget
Automatisation in development and testing - within budgetAutomatisation in development and testing - within budget
Automatisation in development and testing - within budgetDavid Lukac
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018Berend de Boer
 
Cucumber Presentation Kiev Meet Up
Cucumber Presentation Kiev Meet UpCucumber Presentation Kiev Meet Up
Cucumber Presentation Kiev Meet Updimakovalenko
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Managerconnectwebex
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructureLindsay Holmwood
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerJustin Edelson
 
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...Rudy Jahchan
 

Ähnlich wie Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli (20)

Software Testing
Software TestingSoftware Testing
Software Testing
 
End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with geb
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?
 
Continuous Quality
Continuous QualityContinuous Quality
Continuous Quality
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web Components
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experiments
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
 
Automatisation in development and testing - within budget
Automatisation in development and testing - within budgetAutomatisation in development and testing - within budget
Automatisation in development and testing - within budget
 
aautoPilot
aautoPilotaautoPilot
aautoPilot
 
Testdroid:
Testdroid: Testdroid:
Testdroid:
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018
 
Cucumber Presentation Kiev Meet Up
Cucumber Presentation Kiev Meet UpCucumber Presentation Kiev Meet Up
Cucumber Presentation Kiev Meet Up
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Manager
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Manager
 
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
 

Kürzlich hochgeladen

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 

Kürzlich hochgeladen (20)

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 

Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli

  • 1. Copyright © 2015 spriteCloud B.V. All rights reserved. Introduction to Cucumber with Lapis Lazuli Getting Started with Test Automation
  • 2. Copyright © 2015 spriteCloud B.V. All rights reserved. Getting started: This presentation will take you through the steps needed to set up a test automation project using Cucumber - a software tool that runs automated tests in the BBD style - in combination with Lapis Lazuli, a gem that provides Cucumber helper functions and scaffolding for easier web test automation suite development. To do this you will need to have installed Ruby with some drivers and libraries. You can find detailed notes on how to do this here: http://www.testautomation.info/Getting_Started
  • 3. Copyright © 2015 spriteCloud B.V. All rights reserved. What you need: To successfully follow this tutorial, prior knowledge of test automation isn’t needed, but knowledge of scripting - especially Ruby - and HTML skills are recommended.
  • 4. Copyright © 2015 spriteCloud B.V. All rights reserved. You will find out about: - Gherkin - Cucumber - Browser testing - Creating a TA project - Best practices
  • 5. Copyright © 2015 spriteCloud B.V. All rights reserved. Example website To set up this project, we will test on a small web application as an example. Try the following steps out at: http://www.testautomation.info/training-page/ Note: The web app doesn’t store information, closing the browser window will reset the page and created user accounts.
  • 6. Copyright © 2015 spriteCloud B.V. All rights reserved. HTML introduction Firstly, this is HTML Structure you will need to refer to: <parent> <element> <child></child> <child></child> </element> <element/> </parent> HTML Element: <a id="homepage" href="http://www.spritecloud.com"> spriteCloud </a> Element (node) Attribute (node) name Attribute (node) value Text (node)
  • 7. Copyright © 2015 spriteCloud B.V. All rights reserved. Code examples A very short explanation of code you need during this training: A variable is a label you can give to a piece of data. Data can be simple (numbers, text, functions) or complex. Complex data or objects contain variables. Functions return data based on certain input data. # This is a comment variable = "string" variable2 = :symbol variable3 = 1000 * 3 + 200 Object.variable puts("Hello World!") => "Hello World!" $ program "on commandline" # Red is used as a highlight
  • 8. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing Install Lapis Lazuli with: $ gem install lapis_lazuli Run the Interactive Ruby Shell $ irb # Load the library require("lapis_lazuli") # Activate LL in this IRB session include(LapisLazuli) # Goto the website browser.goto("http://www.testautomatio n.info/training-page/") # Print the page title browser.title() => "Calliope Training"
  • 9. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing Finding elements on page using LL uses the .find / .find_all function. It allows you to do complex searches, but today we will focus on the basics. # Find the title # using the unique ID attribute browser.find("title").text() # or the longer syntax browser.find({:id => "title"}) # Number of links on a page # using the element browser.find_all(:a).length()
  • 10. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing Sometimes elements don’t have an ID and you will have to use other attributes. # Number text fields on the page # using attributes browser.find_all({:like => { :element => "input", :attribute => "type", :include => "text"}} ).length() # or a short notation browser.find_all({ :like => ["input","type","text"] })
  • 11. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing Website automation requires more interaction than loading pages and finding elements. Start by clicking the login button # Find the login button # and save it in a variable login = browser.find({ :id => "button-login" }) # Correct button? login.flash() # Click the button login.click()
  • 12. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing To do a successful login we need to enter our credentials: # Username text field username = browser.find({ :id => "login-username" }) # Enter the username username.send_keys("test") # Repeat with password field # Do the login login.click() Username test Password test
  • 13. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing What happens if you try to find an element that doesn’t exist on the page? # Search for not existing element browser.find({:id => "HIDDEN"}) => RuntimeError: Error in find - Cannot find elements with selectors: {:pick=>:first, :mode=>:match_one, :selectors=>[{:element=>"HIDDEN"}]} (http://www.spritecloud.com/)
  • 14. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing The find functions allow you to set your own custom error message to helps non-technical users understand the issue. # Search for not existing element browser.find({ :id => “HIDDEN”, :message => “Could not find hidden element” }) => RuntimeError: Could not find hidden element - Cannot find elements with selectors: { … } (http://www.spritecloud.com/)
  • 15. Copyright © 2015 spriteCloud B.V. All rights reserved. Browser testing Now try it yourself: - Click the first todo item - Add a todo Or try out automating another website, like searching on Google.com
  • 16. Copyright © 2015 spriteCloud B.V. All rights reserved. Technology framework - BDD Language to describe tests - Test specification and execution - Tools to improve Watir for cucumber testing - Tools to improve WebDriver - Browser automation - Programming Language - Cucumber Software-as-a-Service by spriteCloud Lapis Lazuli Watir Selenium WebDriver Ruby Cucumber Gherkin Calliope
  • 17. Copyright © 2015 spriteCloud B.V. All rights reserved. Gherkin Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software's behaviour without detailing how that behaviour is implemented. Gherkin serves two purposes — documentation and automated tests. Feature: Some terse yet descriptive text of what is desired Scenario: Some situation Given some precondition And some other precondition When some action by the actor And some other action And yet another action Then some outcome is achieved And something else we can check
  • 18. Copyright © 2015 spriteCloud B.V. All rights reserved. Gherkin For the feature description, a three- line user story is ideal: ● In order to <achieve goal> ● As a <role> ● I want to <activity details> Feature: Todo Clicking In order to complete a todo As a test automation novice I want to click a todo Scenario: Regular numbers Given I am logged in When I click the fist todo Then 2 todos remain
  • 19. Copyright © 2015 spriteCloud B.V. All rights reserved. Cucumber Cucumber is a software tool that computer programmers use for testing other software. It runs automated acceptance tests written in a behavior-driven development (BDD) style. Given /I am logged in/ do browser.goto "http://www.testautomation.info/training-page/" end When /I click the first todo/ do browser.find("todo-item-0").click end Then /(d+) todos remain/ do |number| browser.find("todo-remaining") # … some extra code end
  • 20. Copyright © 2015 spriteCloud B.V. All rights reserved. Cucumber Given /I am logged in/ do browser.goto "http://www.testautomation.info/training-page/" end When /I click the first todo/ do browser.find("todo-item-0").click end Then /(d+) todos remain/ do |number| browser.find("todo-remaining") end Feature: Todo Clicking In order to complete a todo As a test automation novice I want to click a todo Scenario: Regular numbers Given I am logged in When I click the fist todo Then 2 todos remain
  • 21. Copyright © 2015 spriteCloud B.V. All rights reserved. Starting a new project To create a project type: $ lapis_lazuli create MyTaTraining The project already includes an example scenario, so lets run it: $ cd MyTaTraining/ $ cucumber MyTaTraining/ config/ config.yml cucumber.yml features/ example.feature step_definitions/ interaction_steps.rb validation_steps.rb support/ env.rb
  • 22. Copyright © 2015 spriteCloud B.V. All rights reserved. Cucumber result Let’s look at the cucumber output: Scenario: example01 - Google Search # example.feature:8 Given I navigate to Google in english # interaction_steps.rb:6 And I search for "spriteCloud" # interaction_steps.rb:16 Then I see "www.spriteCloud.com" on the page # validation_steps.rb:6 1 scenario (1 passed) 3 steps (3 passed) 0m9.976s
  • 23. Copyright © 2015 spriteCloud B.V. All rights reserved. Cucumber result Let’s look at the cucumber output: Scenario: example01 - Google Search #example.feature:8 Given I navigate to Google in english # interaction_steps.rb:6 And I search for "spriteCloud" # interaction_steps.rb:16 Then I see "www.spriteCloud.com" on the page # validation_steps.rb:6 1 scenario (1 passed) 3 steps (3 passed) 0m9.976s MyTaTraining/ config/ config.yml cucumber.yml features/ example.feature step_definitions/ interaction_steps.rb validation_steps.rb support/ env.rb
  • 24. Copyright © 2015 spriteCloud B.V. All rights reserved. Cucumber options By default Cucumber will run all feature files it can find, but it has multiple options for customized runs Advanced: To view all options $ cucumber --help # Using feature file $ cucumber features/test.feature # With line number $ cucumber features/test.feature:10 # Run a single tag $ cucumber --tags @example # Run two tags (logical OR) $ cucumber -t @example,@dev # Run scenario with both tags (AND) $ cucumber -t @example -t @dev # Excluding a tag $ cucumber -t ~@dev # Check which scenarios will run $ cucumber --dry-run
  • 25. Copyright © 2015 spriteCloud B.V. All rights reserved. TA Best practices 1. Don’t add ‘code’ to Gherkin 2. Validate if a step has been completed 3. Try to use XPath or the like and not RegExp 4. Don’t use hard timeouts 5. Work with the development team 6. Use shortest possible selector 7. Scenarios are independent 8. Keep your code clean and simple

Hinweis der Redaktion

  1. Orange : Website link
  2. Red highlight: .goto
  3. For colourblind Gijs: Blue : Class/Modules Dark Blue : Variables Green : Hardcoded values Red : Highlighting Orange : CMD Light Grey : Comment Very Light Grey : Brackets that can be removed Dark Grey : Output Brownish : Functions Black : Other Syntax
  4. Red highlight: .goto
  5. Red highlight: .find, .find_all
  6. Red highlight: .find, .find_all
  7. Red highlight: Error in find, URL
  8. Red highlight: Custom error message “Could not find doesnotexist”
  9. Dark Green : Gherkin Light Green : Cucumber Blue : Lapis Lazuli Light Blue : Watir Very Light Blue: Selenium WebDriver Red : Ruby Orange : Calliope
  10. Orange : Feature Blue : Scenario Red : Given Green : When Purple : Then Black : And
  11. Orange : Feature Blue : Scenario Red : Given Green : When Purple : Then Black : And
  12. Orange : Feature Blue : Scenario Dark Blue : Variables Red : Given Green : When Purple : Then
  13. Orange : Feature Blue : Scenario Dark Blue : Variables Red : Given Green : When Purple : Then
  14. Blue : config.yml => Lapis Lazuli Green : example.feature => Gherkin Light Green : cucumber.yml, *_steps.rb => Cucumber Red : env.rb => Ruby Purple : features/ => Most important folder for now
  15. Green : example.feature Light Green : *.rb
  16. Green : example.feature Light Green : *.rb Orange : Line numbers Editor walkthrough, show every file, explain parts like: example.feature what tags are new features are just plain files in features/ folder step definitions difference between interaction and validation steps interaction_steps.rb How do the steps work LL functions: has_env?, env, error, log validation_steps.rb browser.wait config files difference between configs config.yml how do environments work error strings cucumber.yml what are cucumber profiles env.rb require statements World(LapisLazuli)
  17. Orange : Cucumber commands
  18. Show slide at the end of the presentation