Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "11 Introduction to UI testing with SWAT 2/12/2011."— Presentation transcript:

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

2 22 Ultimate is a 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. Ultimate Software

3 33 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 44 Full-time and Internship positions Resumes or Connect on LinkedIN: Best Mid-Size Company to Work for in America 2008 & 2009

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

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

7 77 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 88 Why Test Through the UI Testing Pyramid

9 99 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 10 Demo

11 11 Browsers Currently Supported Browsers –IE –Firefox –Chrome –Safari on OSX

12 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 13 How commands are entered (fitnesse\editor) All test blocks start with !|SWATFixture| Commands come underneath Example: !|SWATFixture| |OpenBrowser| |NavigateBrowser|www.google.com|

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

15 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 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 17 Standard command parameters Identifier Type –http://ulti-swat.wikispaces.com/QS_Fitnesse_IdentifierTypeshttp://ulti-swat.wikispaces.com/QS_Fitnesse_IdentifierTypes –ID –Name –InnerHTML –Expression (we will get to this one in a moment) Identifier –Example my label –|id|myID| –|InnerHTML|my label| –NOTE* when using an identifier other then Expression must be exact Tagname –Optional –Speeds up tests –Recommended

18 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|tagNa me(optional)| –Attribute The Attribute that will be set Could be value, class, style, etc –Attribute Value Value you want to set it to

19 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 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 21 Where we are now (Fitnesse \ Editor) !|InternetExplorerSWATFixture| !|SWATFixture| |OpenBrowser| |NavigateBrowser|www.google.com| !|SWATFixture| |SetElementAttribute|name|q|value|Ultimate Software|input| |StimulateElement|name|btnG|onclick|input| !|SWATFixture| |CloseBrowser|

22 22 Expressions Allow more powerful searches Can string together multiple attributes : vs = –: means contains –= means exact ‘;’ used to break up attributes Example – my label –Expression|id=myID;innerHTML:my lab| Uses regular expressions NOTE* –Period ‘.’ is a wild card, can mean anything

23 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

24 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 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 26 SQL SWAT has a host of SQL functions built in Connecting to a SQL Server !|SWATFixture| |ConnectToMssql|dbServer|username|password| |SetDatabase|dbName|

27 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 28 SWAT Editor Included in SWAT download from sourceforge Up to date walk-throughs here: –http://ulti-swat.wikispaces.com/QS_SwatEditorhttp://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 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 30 Where to get help Questions –https://sourceforge.net/projects/ulti-swat/https://sourceforge.net/projects/ulti-swat/ –Open forum on sourceforge Websites –http://ulti-swat.wikispaces.com/http://ulti-swat.wikispaces.com/ –http://devxero.wordpress.com/http://devxero.wordpress.com/

31 31 Questions? Thank you for your attention


Download ppt "11 Introduction to UI testing with SWAT 2/12/2011."

Similar presentations


Ads by Google