Upload
alexander-polovinko
View
25
Download
0
Tags:
Embed Size (px)
Citation preview
Practical aspects of UI automation using Cucumber and Capybara
by Alex Polovinko3/14/2105
Automation frameworks
• What is all this about?
#Software with additional functionality: run:
pass/fail
• From complexity to simplicity
#Abstraction is the point.
• Cucumber
# Simple, human collaboration: BDD that talks to
domain experts first and code second
# Cucumber lets software development teams
describe how software should behave in plain text.
The text is written in a
business-readable domain-specific language and
serves as documentation, automated tests and
development-aid – all rolled into one format.
• Platforms and permutations
#https://cukes.info/platforms
Gherkin and Cucumber architecture
1. Format for Cucumber Specifications.#small computer language with a well-defined syntax
2. When you run Cucumber, it will generate
a report that verifies whether or not the
software behaves the way the Gherkin
document says.
3. Gherkin DSL and units#features/scenarios/steps
4. How that works?
5. Additional capabilities:#flexible step definitions
#tables
#examples
#calling steps from steps
#I18N
Capybarahttp://www.rubydoc.info/github/jnicklas/capybara
#Capybara is a library (Gem) written in the Ruby
programming language which makes it easy to simulate how a
user interacts with your application
#Capybara is acting as an abstraction layer over the driver.
Agnostic about the driver running your tests and comes with
Selenium support built in
#Capybara also comes with a built in DSL for creating
descriptive acceptance tests (Intuitive API which mimics the
language an actual user would use):
Navigating/Clicking links and buttons/Interacting with
forms/Querying/Finding/Scoping/Working with
windows/Scripting/Modals/Debugging
https://gist.github.com/zhengjia/428105
http://www.rubydoc.info/github/jnicklas/capybara/master
#Drivers
Capybara uses the same DSL to drive a variety of browser and headless
drivers.
Webdriver, native events.
Ruby• Ruby
Gems
Rails• Gemfile
CucumberGherkin
Capybara• Registerin
g drivers
First scenario• It’s
working!!!
Setup
+ RSpec to wrap it up
Challenges and Lessons learned
• Locators and browser specific Xpaths
• Iframes/windows
• Asynchronous JavaScript (Ajax and friends)
• Cross-site scripting prevention
• SSL alerts/modals handling
• FF profile settings
• Arbitrary JS (visibility of elements, mouse hover), JS engines
• Assertions (RSpec)/soft assertions handling
• State transitioning between steps/execution metadata
• Uniq scenarios and special chars in scenarios
Things you need to think of while developing scripts
o Good automation candidate:
#positive
#saving time
#robust
#false negatives
#cost of execution
o Critical/Smoke/Sanity/Regression
o Concept of orthogonal testing/coverage.
o Concept of tags: (wip, stories)
o Environmental variables, scalability, modularity
o Reusablity, common libraries. D(on’t)R(epeat)Y(ouself)
Platform/browsers/SauceLabs
Before/after hooks
Screenshots
Scenarios metadata and
cli
Scripts enhancements
Dev:
While developing
feature / autocommit
IDE integration
QA:
Functional testing
debugging
reproducing
Sandbox:
UAT
Integration/Regression
Scheduling/batch files
Parallel/consequent
CI integration/Jenkins
rerun
Scripts execution in different environments
Reporting or How to make your manager be happy
Report
Pretty
JSON
Custom formats
Plugins/Jenkings
HTML
Looking Ahead
• Questions?
Appendix
http://cuke4ninja.com/https://cukes.info/https://github.com/jnicklas/capybarahttp://testerstories.com/2014/08/learning-capybara-part-1/http://www.sitepoint.com/basics-capybara-improving-tests/