38
Making Watir and Cucumber an efficient tool for Web UI Automation Ruslan Strazhnyk nCryptedCloud

Making Watir and Cucumber an efficient tool for Web UI Automation

Embed Size (px)

Citation preview

Page 1: Making Watir and Cucumber an efficient tool for Web UI Automation

Making Watir and Cucumber an

efficient tool for Web UI

Automation

Ruslan Strazhnyk

nCryptedCloud

Page 2: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 3: Making Watir and Cucumber an efficient tool for Web UI Automation

So many Frameworks?!

Page 4: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 5: Making Watir and Cucumber an efficient tool for Web UI Automation

Experience with RF

Page 6: Making Watir and Cucumber an efficient tool for Web UI Automation

Robot Framework

Page 7: Making Watir and Cucumber an efficient tool for Web UI Automation

Robot Framework

Page 8: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 9: Making Watir and Cucumber an efficient tool for Web UI Automation

Behave

Page 10: Making Watir and Cucumber an efficient tool for Web UI Automation

Behave

Page 11: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 12: Making Watir and Cucumber an efficient tool for Web UI Automation

JavaScript Frameworks

Page 13: Making Watir and Cucumber an efficient tool for Web UI Automation

JavaScript Frameworks

Page 14: Making Watir and Cucumber an efficient tool for Web UI Automation

JavaScript Frameworks

Page 15: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 16: Making Watir and Cucumber an efficient tool for Web UI Automation

Advantages of Watir

No xpath

No Selenium IDE

The power or Ruby

Rich API

Page 17: Making Watir and Cucumber an efficient tool for Web UI Automation

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 18: Making Watir and Cucumber an efficient tool for Web UI Automation

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 19: Making Watir and Cucumber an efficient tool for Web UI Automation

Page Object

Define new page object

Add some methods, let’s say for login page

Page 20: Making Watir and Cucumber an efficient tool for Web UI Automation

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 21: Making Watir and Cucumber an efficient tool for Web UI Automation

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 22: Making Watir and Cucumber an efficient tool for Web UI Automation

Page Object Elementsttps://github.com/cheezy/page-object/wiki/Elements

ListItem

OrderedList

Paragraph

RadioButton

SelectList (Dropdown)

Span

Table

TableCell

TextArea/TextField

UnorderedList

Page 23: Making Watir and Cucumber an efficient tool for Web UI Automation

Hooks

Scenario hooks

Before

After

Around

Step hooks

Tagged hooks

Global hooks

AfterConfiguration

Page 24: Making Watir and Cucumber an efficient tool for Web UI Automation

Hooks

Before and After hooks

Page 25: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 26: Making Watir and Cucumber an efficient tool for Web UI Automation

Tagging

Page 27: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 28: Making Watir and Cucumber an efficient tool for Web UI Automation

Scenario vs. Scenario Outline

Page 29: Making Watir and Cucumber an efficient tool for Web UI Automation

Advanced element usage

File Upload (steps and step definitions)

Page 30: Making Watir and Cucumber an efficient tool for Web UI Automation

Advanced element usage

File Upload (function)

Page 31: Making Watir and Cucumber an efficient tool for Web UI Automation

Advanced element usage

Looping through file links

Page 32: Making Watir and Cucumber an efficient tool for Web UI Automation

Advanced features: iFrame, inFrame

Page 33: Making Watir and Cucumber an efficient tool for Web UI Automation

Advanced features: iFrame, inFrame

Page 34: Making Watir and Cucumber an efficient tool for Web UI Automation

Advanced features: JS Pop-ups

Alert, Confirm, Prompt

Page 35: Making Watir and Cucumber an efficient tool for Web UI Automation

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

Page 36: Making Watir and Cucumber an efficient tool for Web UI Automation

Continuous Integration with

Jenkins

Page 37: Making Watir and Cucumber an efficient tool for Web UI Automation

Continuous Integration with

Jenkins

Page 38: Making Watir and Cucumber an efficient tool for Web UI Automation

Questions? Ideas? Follow-up?

• Twitter @strazhnyk

• Skype ruslanstrazhnyk

• Email [email protected]

• LinkedIn ruslanstrazhnyk