Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Coded UI: Hand Coding based on Page Object Model


Published on

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.

  • I'm building hand-code Coded UI Tests, which I write about in my blog.

    Some posts:

    Are you sure you want to  Yes  No
    Your message goes here

Coded UI: Hand Coding based on Page Object Model

  1. 1. Software automation using Visual Studio-CodedUI
  2. 2. What is CodedUI• Integrated Testing tool for UI Automation which comeswith Visual Studio (Premium & Ultimate)• Supports both Web and Win application User Interface(UI) Test automation
  3. 3. Support Matrix
  4. 4. 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.
  5. 5. 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
  6. 6. 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)
  7. 7. Page objects• Within your web apps 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”
  8. 8. Interacting Objects
  9. 9. 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
  10. 10. Identifying objects• Using asserting feature of CodedUI
  11. 11. 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.
  12. 12. 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