html5-img
1 / 31

Introduction to UI testing with SWAT

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

faxon
Download Presentation

Introduction to UI testing with SWAT

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to UI testing with SWAT 2/12/2011

  2. 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.

  3. 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

  4. Full-time and Internship positions Email Resumes or Connect on LinkedIN: Greg_Miller@UltimateSoftware.com Best Mid-Size Company to Work for in America 2008 & 2009

  5. Who Am I??? • Michael Longin – Ultimate Software • Lead Process Engineer \ Software Engineer • Certified Scrum Master • Project Lead - SWAT

  6. Goals for this session • Attendees should be able to create and update UI tests

  7. Syllabus • 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?

  8. Why Test Through the UI Testing Pyramid

  9. 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

  10. Demo

  11. Browsers • Currently Supported Browsers • IE • Firefox • Chrome • Safari on OSX

  12. Choosing a browser in a test • C# var _browser = new WebBrowser(BrowserType.InternetExplorer)  or var _browser = new WebBrowser(BrowserType.FireFox) • Editor \ Fitnesse • First line of the test !|InternetExplorerSWATFixture| or !|FireFoxSWATFixture| • SHOULD ONLY BE IN A TEST ONCE!!!

  13. How commands are entered (fitnesse\editor) • All test blocks start with !|SWATFixture| • Commands come underneath • Example: !|SWATFixture| |OpenBrowser| |NavigateBrowser|www.google.com|

  14. Navigation • Open Browser • |OpenBrowser| • _browser.OpenBrowser() • Navigate Browser • Syntax • |NavigateBrowser|url| • _browser.NavigateBrowser(string url) • Example • |NavigateBrowser|www.google.com|

  15. 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()

  16. Where we are now • C# var _browser = new WebBrowser(BrowserType.InternetExplorer)  _browser.OpenBrowser(); _browser.NavigateBrowser(“www.google.com”); _browser.CloseBrowser(); • Editor \ Fitnesse !|InternetExplorerSWATFixture| !|SWATFixture| |OpenBrowser| |NavigateBrowser|www.google.com| |CloseBrowser|

  17. Standard command parameters • Identifier Type • http://ulti-swat.wikispaces.com/QS_Fitnesse_IdentifierTypes • 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

  18. 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

  19. 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

  20. Where we are now (C#) var _browser = new WebBrowser(BrowserType.InternetExplorer)  _browser.OpenBrowser(); _browser.NavigateBrowser("www.google.com"); _browser.SetElementAttribute(IdentifierType.Name, "q", AttributeType.Custom, "value", "South Florida Code Camp", "INPUT"); _browser.StimulateElement(IdentifierType.Name, "btnG", "onclick", "INPUT"); _browser.CloseBrowser();

  21. Where we are now (Fitnesse \ Editor) !|InternetExplorerSWATFixture| !|SWATFixture| |OpenBrowser| |NavigateBrowser|www.google.com| !|SWATFixture| |SetElementAttribute|name|q|value|UltimateSoftware|input| |StimulateElement|name|btnG|onclick|input| !|SWATFixture| |CloseBrowser|

  22. Expressions • Allow more powerful searches • http://ulti-swat.wikispaces.com/Expressions+Explained • 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

  23. 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 parentElement.id:pid;class:hide • <tr id=“pid”><td class=“hide”></td></tr>

  24. 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<<

  25. 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

  26. SQL • SWAT has a host of SQL functions built in • Connecting to a SQL Server !|SWATFixture| |ConnectToMssql|dbServer|username|password| |SetDatabase|dbName|

  27. 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

  28. SWAT Editor • Included in SWAT download from sourceforge • Up to date walk-throughs here: • http://ulti-swat.wikispaces.com/QS_SwatEditor • 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

  29. 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)

  30. Where to get help • Questions • https://sourceforge.net/projects/ulti-swat/ • Open forum on sourceforge • Websites • http://ulti-swat.wikispaces.com/ • http://devxero.wordpress.com/ • Email • Michael_Longin@ultimatesoftware.com

  31. Questions? • Thank you for your attention

More Related