Introduction to ui testing with swat
1 / 31

Introduction to UI testing with SWAT - PowerPoint PPT Presentation

  • Uploaded on

Introduction to UI testing with SWAT. 2/12/2011. Ultimate Software.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about ' Introduction to UI testing with SWAT' - efuru

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Ultimate software
Ultimate Software

Ultimate isa leading provider of unified human capital management SaaS solutions for global businesses. Its award-winning UltiPro® includes recruitment, onboarding, benefits management, payroll, performance and learning management, reporting, self-service, and more.

About ultimate software
About Ultimate Software

  • Founded in 1990

  • Dedicated focus on HR, payroll, benefits, talent management

  • Award-winning UltiPro® product and customer services

  • 1100 employees

  • 250 people in development

  • 15 large kanban teams

  • .NET, MSSQL, Delphi shop

  • Headquarters in Weston, FL

Full time and internship positions
Full-time and Internship positions

Email Resumes or Connect on LinkedIN:

[email protected]

Best Mid-Size Company to Work for in America 2008 & 2009

Who am i
Who Am I???

  • Michael Longin – Ultimate Software

    • Lead Process Engineer \ Software Engineer

    • Certified Scrum Master

    • Project Lead - SWAT

Goals for this session
Goals for this session

  • Attendees should be able to create and update UI tests


  • Why Test Through the UI

  • Introduction to SWAT

  • Running tests against different browsers (IE\Firefox\Chrome)

  • Navigating

  • Bread and Butter Commands

  • The concept of expressions

  • Variables

  • Command Modifiers

  • Macros

  • SWAT Editor

  • Where to get help

  • Questions?

Why test through the ui
Why Test Through the UI

Testing Pyramid

An introduction to swat
An Introduction to SWAT

  • SWAT

    • Simple Web Automation Toolkit

    • Meant to provide a simple way to test the UI of a website

    • C# Library

  • Library of commands

    • UI

    • Database

  • Not tied to the included editor, fitnesse, or any other runner

  • Open Source

    • Anyone can download the program and the source


  • Currently Supported Browsers

    • IE

    • Firefox

    • Chrome

    • Safari on OSX

Choosing a browser in a test
Choosing a browser in a test

  • C#

    var _browser = new WebBrowser(BrowserType.InternetExplorer) 


    var _browser = new WebBrowser(BrowserType.FireFox)

  • Editor \ Fitnesse

    • First line of the test





How commands are entered fitnesse editor
How commands are entered (fitnesse\editor)

  • All test blocks start with !|SWATFixture|

  • Commands come underneath

  • Example:





  • Open Browser

    • |OpenBrowser|

    • _browser.OpenBrowser()

  • Navigate Browser

    • Syntax

      • |NavigateBrowser|url|

      • _browser.NavigateBrowser(string url)

    • Example

      • |NavigateBrowser||

Navigation continued
Navigation continued

  • Attach to Window

    • Used to attach to an open browser or popup

    • Does not need to be exact

    • |AttachToWindow|WindowTitle|

    • _browser.AttachToWindow(string windowTitle)

  • Close Browser

    • |CloseBrowser|

    • _browser.CloseBrowser()

Where we are now
Where we are now

  • C#

    var _browser = new WebBrowser(BrowserType.InternetExplorer) 




  • Editor \ Fitnesse






Standard command parameters
Standard command parameters

  • Identifier Type


    • ID

    • Name

    • InnerHTML

    • Expression (we will get to this one in a moment)

  • Identifier

    • Example <label id=“myID”>my label</label>

    • |id|myID|

    • |InnerHTML|my label|

    • NOTE* when using an identifier other then Expression must be exact

  • Tagname

    • Optional

    • Speeds up tests

    • Recommended

Bread and butter commands
Bread and Butter commands

  • Checking for an item on the page

    • AssertElementExists

    • Used to determine if an element is on the screen

    • |AssertElementExists|IdentifierType|identifier| tagName(optional)|

  • Setting the value of an attribute

    • SetElementAttribute

    • Could be used to set a textbox

    • |SetElementAttribute|IdentifierType|identifier|attributeName|attributeValue|tagName(optional)|

    • Attribute

      • The Attribute that will be set

      • Could be value, class, style, etc

    • Attribute Value

      • Value you want to set it to

Bread and butter continued
Bread and Butter continued

  • Firing an attributes events

    • StimulateElement

    • Could be used to click a button or change a drop down

    • |StimulateElement|IdentifierType|identifier|eventName| tagName(optional)|

    • EventName

      • Onclick, OnChange, OnBlur, etc

Where we are now c
Where we are now (C#)

var _browser = new WebBrowser(BrowserType.InternetExplorer) 



_browser.SetElementAttribute(IdentifierType.Name, "q", AttributeType.Custom, "value", "South Florida Code Camp", "INPUT");

_browser.StimulateElement(IdentifierType.Name, "btnG", "onclick", "INPUT");


Where we are now fitnesse editor
Where we are now (Fitnesse \ Editor)











  • Allow more powerful searches


  • Can string together multiple attributes

  • : vs =

    • : means contains

    • = means exact

  • ‘;’ used to break up attributes

  • Example

    • <label id=“myId”>my label</label>

    • Expression|id=myID;innerHTML:my lab|

  • Uses regular expressions

  • NOTE*

    • Period ‘.’ is a wild card, can mean anything

Expressions continued
Expressions continued

  • Matchcount

    • Check for multiple instances

    • Example: innerHTML#2:ulti

      • Reads as, “ulti” must be contained twice in the HTML

  • ParentElement

    • Can use the parent element

    • Example;class:hide

      • <tr id=“pid”><td class=“hide”></td></tr>

Variables fitnesse editor
Variables (Fitnesse \ Editor)

  • Can be used as part of an expression or as an identifier

  • Design time

    • Used to create a variable when your writing the tests

    • When to use

      • When something is likely to change

      • When something is repeated often

    • To Set

      • !define loginUserName (atnipj)

    • To Use

      • ${loginUserName}

      • Expression|id:${myID}

  • Run Time

    • Variables that are populated when running the test

    • When to use

      • When a variable is needed that can only be set at the time of running

    • To Set

      • |GetElementAttribute|IdentifierType|identifier|attributeName|YourVariableName|tagName|

    • To Use

      • >>YourVariableName<<

      • Expression|id:>>myID<<

Macros fitnesse editor
Macros (Fitnesse \ Editor)

  • In C# would be known as methods

  • Very powerful

  • In fitnesse each test can be used in any other test

  • Macros can take in variables

  • Reasons to use

    • Make tests less brittle

      • Any time an action is done in multiple tests, if the action changes can break all the tests

        • Example: log in

    • Make tests more readable

      • Can turn 5-30 lines of code into a single readable line

        • Example : login macro

    • Make tests more easily updatable

      • Turn the InternetExplorerSWATFixture line into a macro

        • Changing this to Firefox will update all tests to run in firefox

  • How to call a macro

    • !include .SwatMacros.Login

  • Macros are VERY Important and Useful


  • SWAT has a host of SQL functions built in

  • Connecting to a SQL Server




Sql commands
SQL Commands

  • SetQuery

    • Used to run a query against the sql server

    • Results are stored in memory

  • Assert Record Count

    • Verifys how many rows were returned against an expected result

    • |AssertRecordCount|ExpectedNumber|

  • AssertRecordValuesByColumnName

    • Used to verify values in the database

    • |AssertRecordValuesByColumnName|[RowIndex]|ColumnName|ExpectedValue|

  • GetDbRecordByColumnName

    • Used to place the value of a sql check into a variable

    • |GetDbRecordByColumnName|VariableName|[RowIndex]|ColumnName|

  • Others available

Swat editor
SWAT Editor

  • Included in SWAT download from sourceforge

  • Up to date walk-throughs here:


  • Tests can be run\written in the editor

  • SQL query editor

    • Included Database query editor allows you to create Select, Update, Insert, and Delete commands

  • UI recorder is contained in the editor

Final words
Final Words

  • UI tests should be a part of your test plan, but not the only part

  • Recorders are meant to help and be training wheels. They are not meant to do all the work

  • When using Fitnesse as a runner, open it in a browser (IE, Firefox, etc) that is NOT the one you will be running tests against

  • In order to use SWAT to test in Internet Explorer using C# the Apartment State has to be set to STA(Single Threaded Apartment)

Where to get help
Where to get help

  • Questions


    • Open forum on sourceforge

  • Websites



  • Email

    • [email protected]


  • Thank you for your attention