12
Software automation using Visual Studio-CodedUI

Coded UI: Hand Coding based on Page Object Model

Embed Size (px)

DESCRIPTION

Coded UI is a User Interface (UI) Test Automation Tool that comes with Microsoft Visual Studio which can be used to automate our manual, repetitive and regression tests thereby increase productivity of Testing teams.

Citation preview

Page 1: Coded UI: Hand Coding based on Page Object Model

Software automation using Visual Studio-CodedUI

Page 2: Coded UI: Hand Coding based on Page Object Model

What is CodedUI• Integrated Testing tool for UI Automation which comes with Visual Studio (Premium & Ultimate)

• Supports both Web and Win application User Interface (UI) Test automation

Page 3: Coded UI: Hand Coding based on Page Object Model

Support Matrix

Page 4: Coded UI: Hand Coding based on Page Object Model

Cross browser support

• Windows 8 X86 Client/Windows 8 X64/Win7 X64/Win7 X86/Win2k8 R2 SP1

• IE version - IE9/ classic IE10 • Firefox version - 15+• Chrome version - 21+• Visual Studio Ultimate/Premium - VS 2012 RTM + VS 2012

Update 1• Selenium NET Bindings and the Selenium ChromeDriver

on Visual Studio Gallery.

Page 5: Coded UI: Hand Coding based on Page Object Model

Working with CodedUI

• 2 ways we can work with CodedUI– Using built-in Test builder• You simply perform the test manually while the

CUIT Test Builder runs in the background• The code is generated automatically

• Hand-code– Based on “Page Object Model”• Create an Object repository• Write code manually for each object to achieve

the task

Page 6: Coded UI: Hand Coding based on Page Object Model

Why Hand-Coding• Generated code has

– Duplicate scripts– Repeated hardcode

• Cost lot of time to change code– Unmanaged UI control

• One control may be recorded by many times• Hand code

– More control over the code– Increase maintainability– Increase readability– Improve sustainability (reusable objects, data driven, constant

values in .settings file etc)

Page 7: Coded UI: Hand Coding based on Page Object Model

Page objects• Within your web app's UI there are areas that your tests

interact with. • A Page Object simply models these as objects within the test

code. • Reduce duplicated code and if changed %only be

applied in one place.

“The Page Object pattern represents the screens of your web app as a series of objects”

Page 8: Coded UI: Hand Coding based on Page Object Model

Interacting Objects

Page 9: Coded UI: Hand Coding based on Page Object Model

Microsoft.VisualStudio.TestTools.UITesting.HtmlControls

– HtmlSpan– HtmlDiv– HtmlInputButton– HtmlHyperlink– HtmlEdit

public static HtmlEdit txtStepbox(BrowserWindow browser)

{ HtmlEdit stepbox = new HtmlEdit(browser); stepbox.SearchProperties.Add(HtmlEdit.PropertyNames.Name, "_ctl0:_ctl0:orderLines:_ctl3"); return stepbox; }

– HtmlCustom

Page 10: Coded UI: Hand Coding based on Page Object Model

Identifying objects• Using asserting feature of CodedUI

Page 11: Coded UI: Hand Coding based on Page Object Model

UI Technologies for searching controls.

• Internet Explorer Testing: Uses MSHTML, DOM to retrieve properties and identify controls hosted within the Internet Explorer.

• UIA: UI Automation is the new accessibility framework for Microsoft Windows, available on all operating systems that support Windows Presentation Foundation (WPF).

• MSAA: This is picked for Winforms Controls, Win32 controls, MFC applications. All the controls that are not picked up by the above two are picked by MSAA.

Page 12: Coded UI: Hand Coding based on Page Object Model

CUITe• CUITe (Coded UI Test enhanced) Framework• Is a thin layer developed on top of Coded UI Test engine

which helps reduce code, increases readability & maintainability.

Feature List

– Simple to setup and use, just install and refer “CUITe.dll” in your Test project– Object Repository: Keeps UI Object definitions separate from automation code

(no more UIMaps)– Reduces code to <10%: Readable, maintainable, sustainable UI automation code– Treat table as Table (logical way of handling content inside a table)– Web Automation: JavaScript execution support– Supports Silverlight and whatever (Html & Silverlight at this point) Coded UI Test

supports underneath