SlideShare a Scribd company logo
1 of 29
Download to read offline
Intro to Capybara
    Amir Barylko
Capybara


Who am I?
•   Architect

•   Developer

•   Mentor

•   Great cook

•   The one who’s entertaining you for the next hour!
Behavior Driven Dev.


           Text
            Text




                   The rSpec Book
Amir Barylko - Intro to Capybara


Why Projects Fail?
• Delivering   late or over budget

• Delivering   the wrong thing

• Unstable   in production

• Costly   to maintain
Amir Barylko - Intro to Capybara


Improve Quality
• Unit Testing

• Integration Testing

• Acceptance Testing
Amir Barylko - Intro to Capybara


BDD
• Implementing    an application

• by   describing its behavior

• from   the perspective of the stakeholder
Amir Barylko - Intro to Capybara


Outside In Approach


       BDD        TDD
Amir Barylko - Intro to Capybara


Test First
• Write   a test before any line of code

• Write minimum amount of code to make
 the test pass

• Refactor   code to eliminate “smells”
Cucumber
Amir Barylko - Intro to Capybara


Gherkin DSL
•   Business readable DSL

•   Flush out requirements

•   Documentation

•   Automated testing

•   Used by Cucumber,
    SpecFlow, jBehave
Amir Barylko - Intro to Capybara


Gherkin Keywords
• Feature    • Then

• Scenario   • And

• Given      • But

• When
Amir Barylko - Intro to Capybara


Features
Feature: Listing projects
  As a user                           Free        text!
  I Want to see the list of projects
  So I can choose one to see the details

  Scenario: List all projects
     (steps here to implement scenario)

  Scenario: No projects are available
     (steps here to implement scenario)
Amir Barylko - Intro to Capybara


Scenario
Scenario: List all projects
  Given I'm logged in                            Step 1



  And    I have some projects stored             Step 2


  When   I browse the projects                   Step 3



  Then   I should see all of them listed         Step 4
Amir Barylko - Intro to Capybara


Running Features
•   Parse the feature

    •   Parse the scenario

        •   For each scenario

            •   Find a step implementation

            •   Execute the code
Amir Barylko - Intro to Capybara


Matching Step
• Matching   regular expression
 Given I have some projects stored            Feature File




 Given /^I have some projects stored$/
                                              Step Def File
Amir Barylko - Intro to Capybara


Step
Given /^I have some projects stored$/ do
  projects = 10.times { random_valid_project }
  fake_response = create_response(projects)
  FakeWeb.register_uri(....)
end
                                       Plain
                                       Ruby!
Capybara
Amir Barylko - Intro to Capybara


The biggest rodent?
• Gem    to simplify integration tests

• Inspired   by Webrat

• Used   to implement Cucumber steps

• Or   with your favorite testing framework
Amir Barylko - Intro to Capybara


Why?
• Support   for different drivers (browsers)

• Even   a headless driver (capybara-webkit)

• Supports   Rack applications

• But   can be used with any web app!
Amir Barylko - Intro to Capybara


Forms
•   click_link             •   check

•   click_button           •   uncheck

•   click_link_or_button   •   attach_file

•   choose                 •   select_option

•   fill_in(“FirstName”, :with => “John”)
Amir Barylko - Intro to Capybara


Finders
•   all(:css, ‘#user’)
•   all(:xpath, ‘//[@id=user]’)
•   find (throws exception if not found)
•   find_field
•   find_link
•   find_button
•   find_by_id
Amir Barylko - Intro to Capybara


Matchers
•   has_selector?

•   has_no_selector?

•   has_content?

•   has_no_content
Amir Barylko - Intro to Capybara


Javascript
• execute_script(....)

• Only   selenium
 page.driver.browser.switch_to.alert.accept

 page.driver.browser.switch_to.alert.dismiss

 page.driver.browser.switch_to.alert.text
Amir Barylko - Intro to Capybara


Drivers
              Rack?   External?   JS?    Headless?      Windows?


Rack           ✔         ✕        ✕          ✕             ✔
Selenium       ✔         ✔        ✔          ✕             ✔
Webkit         ✔         ✔        ✔          ✔             ✔
Poltergeist    ✔         ✔        ✔          ✔             ✕
Summary
Amir Barylko - Intro to Capybara


Next steps
•   Learn about using capybara DSL

•   Read and follow the Cucumber book

•   Learn about page objects pattern

•   Start with a simple project
Amir Barylko - Intro to Capybara


Resources
• Email: amir@barylko.com,

• Twitter: @abarylko

• Blog: http://orthocoders.com

• Website: http://maventhought.com
Amir Barylko - Intro to Capybara


Resources II
Amir Barylko - Intro to Capybara


Resources III
• Capybara: https://github.com/jnicklas/
 capybara

• Cucumber: https://github.com/cucumber

More Related Content

What's hot

Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)Bruce Li
 
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Bruce Li
 
Call Control Power Tools with Adhearsion
Call Control Power Tools with AdhearsionCall Control Power Tools with Adhearsion
Call Control Power Tools with AdhearsionAdhearsion Foundation
 
Gamemaker - More core objects
Gamemaker - More core objectsGamemaker - More core objects
Gamemaker - More core objectsJoe Healy
 
Advanced Skinning & Styling for Android
Advanced Skinning & Styling for AndroidAdvanced Skinning & Styling for Android
Advanced Skinning & Styling for Androidcephus07
 

What's hot (7)

creative commons about license only with three colors
creative commons about license only with three colorscreative commons about license only with three colors
creative commons about license only with three colors
 
Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)
 
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
 
Call Control Power Tools with Adhearsion
Call Control Power Tools with AdhearsionCall Control Power Tools with Adhearsion
Call Control Power Tools with Adhearsion
 
Gamemaker - More core objects
Gamemaker - More core objectsGamemaker - More core objects
Gamemaker - More core objects
 
Testing Alexa Skill
Testing Alexa SkillTesting Alexa Skill
Testing Alexa Skill
 
Advanced Skinning & Styling for Android
Advanced Skinning & Styling for AndroidAdvanced Skinning & Styling for Android
Advanced Skinning & Styling for Android
 

Similar to DevTeach12-Capybara

PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsAmir Barylko
 
Page objects pattern
Page objects patternPage objects pattern
Page objects patternAmir Barylko
 
Page-objects-pattern
Page-objects-patternPage-objects-pattern
Page-objects-patternAmir Barylko
 
PRDC12 advanced design patterns
PRDC12 advanced design patternsPRDC12 advanced design patterns
PRDC12 advanced design patternsAmir Barylko
 
sdec11-Advanced-design-patterns
sdec11-Advanced-design-patternssdec11-Advanced-design-patterns
sdec11-Advanced-design-patternsAmir Barylko
 
prdc10-Bdd-real-world
prdc10-Bdd-real-worldprdc10-Bdd-real-world
prdc10-Bdd-real-worldAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 
2012 regina TC - 103 quality driven
2012 regina TC - 103 quality driven2012 regina TC - 103 quality driven
2012 regina TC - 103 quality drivenAmir Barylko
 
CPL12-Agile-planning
CPL12-Agile-planningCPL12-Agile-planning
CPL12-Agile-planningAmir Barylko
 
Open source libraries and tools
Open source libraries and toolsOpen source libraries and tools
Open source libraries and toolsAmir Barylko
 
YEG-Agile-planning
YEG-Agile-planningYEG-Agile-planning
YEG-Agile-planningAmir Barylko
 
2012 regina TC - 101 welcome & resources
2012 regina TC - 101 welcome & resources2012 regina TC - 101 welcome & resources
2012 regina TC - 101 welcome & resourcesAmir Barylko
 
Cpl12 continuous integration
Cpl12 continuous integrationCpl12 continuous integration
Cpl12 continuous integrationAmir Barylko
 
PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1Amir Barylko
 
Ro r trilogy-part-1
Ro r trilogy-part-1Ro r trilogy-part-1
Ro r trilogy-part-1sdeconf
 
sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1Amir Barylko
 

Similar to DevTeach12-Capybara (20)

YEG-UG-Capybara
YEG-UG-CapybaraYEG-UG-Capybara
YEG-UG-Capybara
 
PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patterns
 
Page objects pattern
Page objects patternPage objects pattern
Page objects pattern
 
Page-objects-pattern
Page-objects-patternPage-objects-pattern
Page-objects-pattern
 
PRDC12 advanced design patterns
PRDC12 advanced design patternsPRDC12 advanced design patterns
PRDC12 advanced design patterns
 
sdec11-Advanced-design-patterns
sdec11-Advanced-design-patternssdec11-Advanced-design-patterns
sdec11-Advanced-design-patterns
 
prdc10-Bdd-real-world
prdc10-Bdd-real-worldprdc10-Bdd-real-world
prdc10-Bdd-real-world
 
Capybara1
Capybara1Capybara1
Capybara1
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 
2012 regina TC - 103 quality driven
2012 regina TC - 103 quality driven2012 regina TC - 103 quality driven
2012 regina TC - 103 quality driven
 
CPL12-Agile-planning
CPL12-Agile-planningCPL12-Agile-planning
CPL12-Agile-planning
 
Open source libraries and tools
Open source libraries and toolsOpen source libraries and tools
Open source libraries and tools
 
YEG-Agile-planning
YEG-Agile-planningYEG-Agile-planning
YEG-Agile-planning
 
Nuget
NugetNuget
Nuget
 
Agile planning
Agile planningAgile planning
Agile planning
 
2012 regina TC - 101 welcome & resources
2012 regina TC - 101 welcome & resources2012 regina TC - 101 welcome & resources
2012 regina TC - 101 welcome & resources
 
Cpl12 continuous integration
Cpl12 continuous integrationCpl12 continuous integration
Cpl12 continuous integration
 
PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1
 
Ro r trilogy-part-1
Ro r trilogy-part-1Ro r trilogy-part-1
Ro r trilogy-part-1
 
sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1
 

More from Amir Barylko

Functional converter project
Functional converter projectFunctional converter project
Functional converter projectAmir Barylko
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web developmentAmir Barylko
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep diveAmir Barylko
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting trainingAmir Barylko
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessAmir Barylko
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6Amir Barylko
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?Amir Barylko
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideAmir Barylko
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityAmir Barylko
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven DevelopmentAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilitiesAmir Barylko
 
Beutiful javascript with coffeescript
Beutiful javascript with coffeescriptBeutiful javascript with coffeescript
Beutiful javascript with coffeescriptAmir Barylko
 
SDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescriptSDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescriptAmir Barylko
 

More from Amir Barylko (20)

Functional converter project
Functional converter projectFunctional converter project
Functional converter project
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web development
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
No estimates
No estimatesNo estimates
No estimates
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep dive
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting training
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomeness
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6
 
Productive teams
Productive teamsProductive teams
Productive teams
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other side
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivity
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
Refactoring
RefactoringRefactoring
Refactoring
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilities
 
Refactoring
RefactoringRefactoring
Refactoring
 
Beutiful javascript with coffeescript
Beutiful javascript with coffeescriptBeutiful javascript with coffeescript
Beutiful javascript with coffeescript
 
Sass & bootstrap
Sass & bootstrapSass & bootstrap
Sass & bootstrap
 
SDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescriptSDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescript
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingSelcen Ozturkcan
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

DevTeach12-Capybara

  • 1. Intro to Capybara Amir Barylko
  • 2. Capybara Who am I? • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour!
  • 3. Behavior Driven Dev. Text Text The rSpec Book
  • 4. Amir Barylko - Intro to Capybara Why Projects Fail? • Delivering late or over budget • Delivering the wrong thing • Unstable in production • Costly to maintain
  • 5. Amir Barylko - Intro to Capybara Improve Quality • Unit Testing • Integration Testing • Acceptance Testing
  • 6. Amir Barylko - Intro to Capybara BDD • Implementing an application • by describing its behavior • from the perspective of the stakeholder
  • 7. Amir Barylko - Intro to Capybara Outside In Approach BDD TDD
  • 8. Amir Barylko - Intro to Capybara Test First • Write a test before any line of code • Write minimum amount of code to make the test pass • Refactor code to eliminate “smells”
  • 10. Amir Barylko - Intro to Capybara Gherkin DSL • Business readable DSL • Flush out requirements • Documentation • Automated testing • Used by Cucumber, SpecFlow, jBehave
  • 11. Amir Barylko - Intro to Capybara Gherkin Keywords • Feature • Then • Scenario • And • Given • But • When
  • 12. Amir Barylko - Intro to Capybara Features Feature: Listing projects As a user Free text! I Want to see the list of projects So I can choose one to see the details Scenario: List all projects (steps here to implement scenario) Scenario: No projects are available (steps here to implement scenario)
  • 13. Amir Barylko - Intro to Capybara Scenario Scenario: List all projects Given I'm logged in Step 1 And I have some projects stored Step 2 When I browse the projects Step 3 Then I should see all of them listed Step 4
  • 14. Amir Barylko - Intro to Capybara Running Features • Parse the feature • Parse the scenario • For each scenario • Find a step implementation • Execute the code
  • 15. Amir Barylko - Intro to Capybara Matching Step • Matching regular expression Given I have some projects stored Feature File Given /^I have some projects stored$/ Step Def File
  • 16. Amir Barylko - Intro to Capybara Step Given /^I have some projects stored$/ do projects = 10.times { random_valid_project } fake_response = create_response(projects) FakeWeb.register_uri(....) end Plain Ruby!
  • 18. Amir Barylko - Intro to Capybara The biggest rodent? • Gem to simplify integration tests • Inspired by Webrat • Used to implement Cucumber steps • Or with your favorite testing framework
  • 19. Amir Barylko - Intro to Capybara Why? • Support for different drivers (browsers) • Even a headless driver (capybara-webkit) • Supports Rack applications • But can be used with any web app!
  • 20. Amir Barylko - Intro to Capybara Forms • click_link • check • click_button • uncheck • click_link_or_button • attach_file • choose • select_option • fill_in(“FirstName”, :with => “John”)
  • 21. Amir Barylko - Intro to Capybara Finders • all(:css, ‘#user’) • all(:xpath, ‘//[@id=user]’) • find (throws exception if not found) • find_field • find_link • find_button • find_by_id
  • 22. Amir Barylko - Intro to Capybara Matchers • has_selector? • has_no_selector? • has_content? • has_no_content
  • 23. Amir Barylko - Intro to Capybara Javascript • execute_script(....) • Only selenium page.driver.browser.switch_to.alert.accept page.driver.browser.switch_to.alert.dismiss page.driver.browser.switch_to.alert.text
  • 24. Amir Barylko - Intro to Capybara Drivers Rack? External? JS? Headless? Windows? Rack ✔ ✕ ✕ ✕ ✔ Selenium ✔ ✔ ✔ ✕ ✔ Webkit ✔ ✔ ✔ ✔ ✔ Poltergeist ✔ ✔ ✔ ✔ ✕
  • 26. Amir Barylko - Intro to Capybara Next steps • Learn about using capybara DSL • Read and follow the Cucumber book • Learn about page objects pattern • Start with a simple project
  • 27. Amir Barylko - Intro to Capybara Resources • Email: amir@barylko.com, • Twitter: @abarylko • Blog: http://orthocoders.com • Website: http://maventhought.com
  • 28. Amir Barylko - Intro to Capybara Resources II
  • 29. Amir Barylko - Intro to Capybara Resources III • Capybara: https://github.com/jnicklas/ capybara • Cucumber: https://github.com/cucumber