Date post: | 17-Jul-2015 |
Category: |
Technology |
Upload: | ruslan-strazhnyk |
View: | 481 times |
Download: | 1 times |
Making Watir and Cucumber an
efficient tool for Web UI
Automation
Ruslan Strazhnyk
nCryptedCloud
About Me
Ruslan Strazhnyk
Rich experience in creating Test Automation
Frameworks - Front-end, Back-end, API, Load
Testing
Languages: Ruby, Python, Java, JS
Technologies: Selenium, REST, CI, Jenkins, Jmeter
So many Frameworks?!
Why Not Robot Framework?
Pros
Similar to BDD/ATDD test writing
Page Object implemented through Selenium2library plugin
Possible to write extensions in Python
Produces output in html
Cons
Requires building own framework (with extensions)
Requires learning RF own language for writing test scenarios
Indirect webdriver support through Selenium2library
Tests are written in txt files
Experience with RF
Robot Framework
Robot Framework
Why not Behave?
Pros
BDD/ATDD is supported through Gherkin
Libraries in Python
Produces output in json and html
Latest webdriver library supported
More cucumber-like, better than RF in keyword logic
Cons
Page Object is not supported out-of-the-box
Building custom framework layer required
Only basic usage tutorials are available
Behave
Behave
Why not some fancy JS Framework?
Node.js + protractor.js + webdriver.js
Pros
BDD/ATDD is supported through Gherkin in cucumber.js
Page-object through protractor.js
Fresh and buzzy
Robustly works with angular applications
Output in html and json
Cons
Strong knowledge of JS required
Only some basic tutorials available
Immature frameworks, too many of them
Has a high-entry point, more optimized for e2e testing
JavaScript Frameworks
JavaScript Frameworks
JavaScript Frameworks
Why
Ruby/Cucumber/PageObje
ct/Watir?
Pros
Full support of Cucumber
Advanced Page-Object framework as a gem
Rspec makes mocking and assertion more advanced
Excellence of both watir and webdriver
Nice book fromJeff Morgan – “Cucumber and Cheese”
Cons
Can be a separate language stack
Learn other ruby gems for things like mysql, ssh and so on
Advantages of Watir
No xpath
No Selenium IDE
The power or Ruby
Rich API
Page-object gem for Ruby
https://github.com/cheezy/page-object
Assists in creating flexible page-objects for testing
browser based applications
Facilitates creation of abstraction layers in the
tests and makes decoupling easy
Provides simple API interface to the elements on
a page
Page-object gem for Ruby
Works with both watir-webdriver and selenium-
webdriver
Robust way of dealing with Ajax Calls
A clean way of handling JavaScripts pop-ups
A simple way of dealing with Frames and iFrames
Supports most HTML elements
Page Object
Define new page object
Add some methods, let’s say for login page
Creating Page Object
It is possible to create higher level methods that
hide implementation details even further
So usage of the page would become
Page Object Elements
Button
Cell
Checkbox
Div
FileField
ttps://github.com/cheezy/page-object/wiki/Elements
Form
H1, H2, H3, H4, H5, H6
Hidden Field
Image
Link
Page Object Elementsttps://github.com/cheezy/page-object/wiki/Elements
ListItem
OrderedList
Paragraph
RadioButton
SelectList (Dropdown)
Span
Table
TableCell
TextArea/TextField
UnorderedList
Hooks
Scenario hooks
Before
After
Around
Step hooks
Tagged hooks
Global hooks
AfterConfiguration
Hooks
Before and After hooks
Tagging
You can use tags to mark your scenarios
Some tags are user for hooks
There could be many tags for one scenario
Effective execution of needed test scenarios
Tagging
Scenario vs. Scenario Outline
Use different values instead of multiplying scenarios
Allows to more concisely express the example through
the use of placeholders
Scenario Outline steps provide a template which is
never directly run
Problematic for some cucumber Reporting plug-ins in
Jenkins
Scenario vs. Scenario Outline
Advanced element usage
File Upload (steps and step definitions)
Advanced element usage
File Upload (function)
Advanced element usage
Looping through file links
Advanced features: iFrame, inFrame
Advanced features: iFrame, inFrame
Advanced features: JS Pop-ups
Alert, Confirm, Prompt
Continuous Integration with
Jenkins
RVM plugin for executing tests in RVM env
Cucumber-reports or Cucumber Test Result Plugin
for reporting
Xvfb plugin for running tests headless
Build With Parameters for manual execution using
different param
Continuous Integration with
Jenkins
Continuous Integration with
Jenkins
Questions? Ideas? Follow-up?
• Twitter @strazhnyk
• Skype ruslanstrazhnyk
• Email [email protected]
• LinkedIn ruslanstrazhnyk