automated keyword driven framework using selenesse

20
1 Automated Keyword Driven Framework using Selenesse Ameya Naik Rasika Doshi

Upload: indicthreads

Post on 17-Jan-2015

2.394 views

Category:

Technology


4 download

DESCRIPTION

Session Presented at 2nd IndicThreads.com Conference On Software Quality held on 25-26 March 2011 in Pune, India. WEB: http://Q11.IndicThreads.com

TRANSCRIPT

Page 1: Automated keyword driven framework using selenesse

1

Automated Keyword Driven Framework using

Selenesse

Ameya NaikRasika Doshi

Page 2: Automated keyword driven framework using selenesse

2

Challenges in Test Automation

Automation Frameworks

The SeleNesse Framework Selenium

FitNesse

Selenesse Library

Demo

Pros & Cons

Contents

Page 3: Automated keyword driven framework using selenesse

3

Limited Skilled Resources

Tool support

Framework Maintenance

Limited Skilled Resources

Tool support

Framework Maintenance

Understanding the

Automation Scripts

Sharing Results with

Management/Client

Understanding the

Automation Scripts

Sharing Results with

Management/Client

Challenges in Test Automation

Page 4: Automated keyword driven framework using selenesse

4

Automation Frameworks

Page 5: Automated keyword driven framework using selenesse

5

Script actions as well as data are maintained outside of the automation script. Enables documentation of functionality in a tabular format.

Test Scripts are represented as step by step instructions (similar to Manual test cases).

Window Control Action Arguments

Window 1 Menu Click File, Open

Window 2 Pushbutton Click Folder Name

Window 3 Verify Results

Keyword Driven Framework

Page 6: Automated keyword driven framework using selenesse

6

Front EndFront End DriverDriver ToolTool ApplicationApplication

SeleNesse Architecture

Page 7: Automated keyword driven framework using selenesse

7

Open source tool for Functional testing of

web applications.

Supports multiple scripting languages like Java,

C#, Ruby, Python, PHP, Perl, etc

Supports playback on multiple browsers - IE, FF, Chrome, Safari.

Supports multiple operating systems - Windows, Linux, Mac OS X, Solaris, Android*, iPhone* (* Selenium 2.0 and higher)

Fast growing user community.

Selenium

Page 8: Automated keyword driven framework using selenesse

8

Fitnesse is a lightweight, open-source framework for automated testing.

It helps to collaboratively define and organize acceptance / functional tests

It works as a Wiki to easily create and edit Scripts and documentation.

FitNesse

Page 9: Automated keyword driven framework using selenesse

9

Fitnesse Fixtures are the bridges between the tables and the AUT. Fixtures process the table commands and drive the AUT. They capture the

results and send them back to FitNesse.

FitNesse Table:

Fixture Code:public class Division {

private double numerator, denominator;public void setNumerator(double numerator) {this.numerator = numerator;}public void setDenominator(double denominator} {this.denominator = denominator;}public double quotient() {return numerator/denominator;}

}

public class Division {private double numerator, denominator;public void setNumerator(double numerator) {this.numerator = numerator;}public void setDenominator(double denominator} {this.denominator = denominator;}public double quotient() {return numerator/denominator;}

}

Eg. Division

Numerator denominator quotient?

10 2 5.0

12.6 3 4.2

100 4 33

FitNesse Fixtures

Page 10: Automated keyword driven framework using selenesse

10

Developed by Marisa Seal, Dawn Cannan and Chris McMahon.

It is a Fitnesse Fixture that connects to Selenium which connects to the actual AUT (Web project).

FitNesse Table:

Fixture

SlimSelenium1Driver.java

https://github.com/marisaseal/selenesse/blob/master/src/selenesse/SlimSeleniumDriver.java

open www.google.co.in

type; q Selenesse

windowFocus

windowMaximize

click btnG

ensure isTextPresent Selenese

SeleNesse

Page 11: Automated keyword driven framework using selenesse

11

Methods for Verification|check|getText|<locator>|<expected text>||ensure|isTextpresent|controlLocator||reject|isTextpresent|controlLocator| |$checkbox=|get attribute|//img[@id='enableRequest']/@src|

|check|getText|<locator>|<expected text>||ensure|isTextpresent|controlLocator||reject|isTextpresent|controlLocator| |$checkbox=|get attribute|//img[@id='enableRequest']/@src|

Methods for checkbox / Radio buttons|makeChecked|<locator>||makeUnchecked|<locator>||makeChecked|<locator>||makeUnchecked|<locator>|

Note: All Verify methods in Selenium can be accessed as is* methods.

e.g. ‘verifyTextPresent’ becomes ‘isTextPresent’, ‘verifyElementPresent’ becomes ‘isElementPresent’

Special Commands

java -jar fitnesse.jar -c "MyTestPage?test&format=text"java -jar fitnesse.jar -c "MyTestPage?test&format=text"

Command Line Interface

Page 12: Automated keyword driven framework using selenesse

12

Feature Summary

Page 13: Automated keyword driven framework using selenesse

13

Pre-Requisites

Selenium RC – http://seleniumhq.org/download http://saucelabs.com/downloads

FitNesse Server – http://fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad

Selenesse Library – http://github.com/marisaseal/selenesse

Demo

Page 14: Automated keyword driven framework using selenesse

14

Pros Cons

Provides Test Management in a browser. Test assets can be shared on demand.

Programming constructs like loops cannot be used in FitNesse. (can write fixtures / methods in SeleNesse to achieve the same result)

Inherent documentation in Wiki Pages.

Not tested for Huge projects with tens of thousands of test cases.

Scripts can be shared for Manual & Automation tests

Requires 2 servers to be running for FitNesse and Selenium.

Importing from spreadsheet is possible

No commercial support. Have to depend on community for support.

Customizable and Extensible FitNesse syntax / format needs to be learnt.

Hides complexity of code from end users

Quick and Easy Setup

Good fit for Agile Teams.

Pros & Cons

Page 15: Automated keyword driven framework using selenesse

15

?

Questions

Page 16: Automated keyword driven framework using selenesse

16

Ameya [email protected]

Rasika [email protected]

Thank You

Page 17: Automated keyword driven framework using selenesse

17

Page 18: Automated keyword driven framework using selenesse

18

We can create a custom method to the Selenesse JAR file. This method can then be called directly from Fitnesse tables.

public boolean verifyComboItemPresent (String selectLocator, String value) {boolean elementFound = seleniumInstance.isElementPresent(selectLocator);

if (elementFound) {String[] retrievedOptions = seleniumInstance.getSelectOptions(selectLocator);for (int i=0; i<retrievedOptions.length; i++) {

if (retrievedOptions[i].equals(value)) {return true;

}}System.out.println("The requested item '"+value+"' was not found in the Combo box");return false;

}System.out.println("The Combo box was not found on the page");return false;

}

public boolean verifyComboItemPresent (String selectLocator, String value) {boolean elementFound = seleniumInstance.isElementPresent(selectLocator);

if (elementFound) {String[] retrievedOptions = seleniumInstance.getSelectOptions(selectLocator);for (int i=0; i<retrievedOptions.length; i++) {

if (retrievedOptions[i].equals(value)) {return true;

}}System.out.println("The requested item '"+value+"' was not found in the Combo box");return false;

}System.out.println("The Combo box was not found on the page");return false;

}

open http://www.quikr.com/

ensure isTextPresent Welcome to Quikr

verifyComboItemPresent

categoryId Pune

Page 19: Automated keyword driven framework using selenesse

19

Page 20: Automated keyword driven framework using selenesse

20

Order of method execution

The order of method execution is as follows:

1. Find method on fixture, if present execute2. Find method on SystemUnderTest, if present execute3. Find method on installed Library in reversed order of creation. So last one created takes precedence over the ones created earlier.

More on Fixtures…

SYSTEM UNDER TEST

Using SystemUnderTest allows you to let SliM directly invoke a method on your SystemUnderTest without having to create a method in a SliM fixture for it. Currently only available in Java.