Creating Automation tool
By: Radhika Sood
Tags: C Sharp Programming, Automation, Sql

I worked on creation of an automation tool “Platform Client Automation Test Harness” during my eighth semester of engineering. This automation tool has the capability to automate the manual test cases for the product “Quark Publishing Platform”. This blog is based on research and project work I did for 6 months while working as an intern at QuarkXpress Research and Development, Chandigarh.

THE PRODUCT — Quark Publishing Platform

It is a highly configurable solution for complete, automated, end- to-end multichannel publishing. Quark Publishing Platform is purpose-built to support end- to-end publishing needs, from complete manual publishing systems to highly automated workflows. Its capabilities can be described in terms of content Creation, Management, Publishing, and Delivery

Why PLATFORM CLIENT automation was needed?

Manual Software Testing is performed by a human sitting in front of a computer carefully going through application screens, trying various usage and input combinations, comparing the results to the expected behavior and recording their observations. Manual tests are repeated often during development cycles for source code changes and other situations like multiple operating environments and hardware configurations.

Automated Testing Tool is able to playback prerecorded and predefined actions, compare the results to the expected behavior and report the success or failure of these manual tests to a test engineer. Once automated tests are created they can easily be repeated and they can be extended to perform tasks impossible with manual testing. Because of this, savvy managers have found that automated software testing is an essential component of successful development projects

Platform Client Automation requires:

· Microsoft .Net Environment

· White Framework

· UIAVerify

WHITE FRAMEWORK

White is a framework for automating rich client applications based on Win32, WinForms, WPF, Silverlight and SWT (Java) platforms. It is .NET based and does not require the use of any proprietary scripting languages. Tests/automation programs using White can be written with whatever .NET language, IDE and tools you are already using. White provides a consistent object-oriented API, hiding the complexity of Microsoft’s UIAutomation library (on which White is based) and windows messages.

White works on top of UIAutomation framework of .Net. If you intend to or have third party controls in your application, you should verify whether they these controls are supported by UIA.When any controls is supported the tool would show you the inner details of the control in a tree form.

White is open-source, written in C# and it supports all rich client applications, which are Win32,WinForm, WPF and SWT (Java). It is .NET based and does not require the use of any proprietary scripting languages. It provides a consistent object oriented API and it hides all the complexity of Microsoft’s UI Automation library and Win32 Windows messages.

The white framework will interact with an application through UI elements. So, you have to be ready with some UI elements inspection tool to find out the Automation ID and many more properties. For that purpose, you can use UISpy and VisualUIAVerify.

UISpy is a standalone executable which enables developers to view all UI elements and their details.

GETTING HOLD OF A WINDOW

Application application = Application.Launch(“age.exe”);

Window window = application.GetWindow(“bar”, InitializeOption.NoCache);

FINDING A UI ITEM AND PERFORMING ACTION

Button button = window.Get<Button>(“save”);

button.Click();

FINDING A UIITEM BASED ON SEARCHCRITERIA

SearchCriteria searchCriteria = SearchCriteria.ByAutomationId(“name”).AndControlType( typeof(TextBox)).AndIndex(2);

TextBox textBox = (TextBox) window.Get(searchCriteria);

textBox.Text = “XYZ”;

UIITEM IDENTIFICATION

SearchCriteria searchCriteria = SearchCriteria.ByAutomationId(“btnOK”);

Button button = window.Get<Button>(“btnOK”); //default search mechanism is by automation id

button = window.Get<Button>(searchCriteria); // is same for unmanaged applications

Button button = window.Get<Button>(“OK”); //default search mechanism is by UIAutomation name

button = window.Get<Button>(SearchCriteria.ByText(“OK”));

Managed UI applications have a mechanism for identifying controls by specifying them names. These names are available for finding controls on using UIAutomation API. Name property used while developing application show up as AutomationId when using UIA API. Unmanaged applications don’t have such feature. In these applications the controls are usu- ally identified by text (white terminology) (name in UIA terminology).

Within a window any UIItem can be identified based combination following criteria.

AUTOMATIONID is the programmatic identifier specified by the AppDeveloper. In WinForm and WPF this is the name supplied to the control. This is not present for SWT and Win32 applications. (applies only to .NET applications WinForm, WPF, Silver- light.)

For managed applications:

SearchCriteria searchCriteria = SearchCriteria.ByAutomationId(“btnOK”);

Button button = window.Get<Button>(“btnOK”); //default search mechanism is by automation id

button = window.Get<Button>(searchCriteria); // is same as above For unmanaged applications:

Button button = window.Get<Button>(“OK”); //default search mechanism is by UIAutomation name

button = window.Get<Button>(SearchCriteria.ByText(“OK”));

UIITEM type (e.g. Button, ComoboBox)

Button button = window.Get<Button>(“btnOK”); //<Button> acts as criteria as well as the return type

button = (Button) window.Get(SearchCriteria.ByAutomationId(“btnOK”).AndControlTy pe(typeof(Button)));

CONTROLTYPE is the ControlType defined in UIAutomation. Since this is same as above these shouldn’t be a reason to use this

button = (Button) window.Get(SearchCriteria.ByControlType(ControlType.Button).And AutomationId(“btnOK”));

TEXT is the additional property defined for accessibility purposes. This property maps to some attribute on UIItem which is visible on the control.

Find the detailed map here:

button = window.Get<Button>(SearchCriteria.ByText(“OK”)); //OK is the display text on the button.

This is much more readable from testing point of view, as it is obvious which button we are interested in. The problem is that in an evolving application the text changes more frequently than the automation id.

Zero based Index of UIItem in case multiple UIItems have same identification based on other parameters. Index is measured from top left corner of the window X first and Y second.

// if there are two buttons with the same automation id.

button = window.Get<Button>(SearchCriteria.ByAutomationId(“btnOK”).AndIndex(1));

Searching based on any UIA property. (Other properties can be found from the class AutomationElement)

The Get method on window can be used only to find PrimaryUIItems. All the primary UIItems are shown with Object Structure. The idea behind the API is to find the primary UIItems first and then work with their specific child items if any.

CLOSING THE WINDOW

window.Close(); //by default it waits while the window is busy.

bool isClosed = window.IsClosed; //isClosed would be true

VISUALUIAVERIFY

With the Visual UIA Verify, you can quickly find and select any UI element anywhere on the desktop. Based on the specific control type and the supported control patterns, UIA Verify provides the built-in test scenarios prioritized for the particular UI element. Developers can add additional test scenarios by adding the code to the UIA Test Library. The tool can output the test results or the summary in various forms. Visual UIA Verify can output test details in HTML. After starting VisualUIAVerify, a UI Automation tree will be displayed. The root element represents the current desktop and the child elements represent application windows. Each of these child elements contain UI elements such as menus, buttons, radiobuttons, textboxes, toolbars, listboxes.

Detailed information about the UI element is displayed in the Properties panel (as shown in the below screen shot). When you want to access a UI element via White, then you need to know the AutomationId, ControlType and Name.

UIA Verify is a test automation framework that features the User Interface Automation Test Library (UIA Test Library) and Visual UI Automation Verify (Visual UIA Verify), the graphical user interface tool. The framework facilitates manual and automated testing of the Microsoft (R) User Interface (UI) Automation Provider implementation of a control or application. The majority of the UIA Verify functionality is provided through a dynamic link library (e.g., UIATestLibrary.dll) that contains the code for testing specific UI Automation functionality and supports logging of the test results.

QUARK PUBLISHING PLATFORM CLIENT: MAC OS X HARDWARE

REQUIREMENT SPECIFICATIONS (MAC )

• 2GB total RAM (4GB recommended)

2GB hard disk space for program files and enough hard disk space to store checked-out assets

• 32-bit or 64-bit

• TCP/IP network

SOFTWARE

• Mac OS X 10.7.x, 10.8.x or 10.9.x

SUPPORTED PLATFORMS

• iMac with Intel Core Duo or Intel Core 2 Duo processor

• MacBook or MacBook Pro with Intel Core Duo or Intel Core 2 Duo processor running Mac OS X client software

• Mac Pro running Mac OS X client software

• Mac mini with Intel Core Duo or Intel Core 2 Duo processor

WEB CONTAINERS

Quark Publishing Platform Server can run in the following Web containers:

• Apache Tomcat (embedded or external) 7.0.29

• Oracle WebLogic 12.1

• IBM WebSphere 8.5

LANGUAGES

• Front-End: Objective C

• Back-End: Hsql

REQUIREMENT SPECIFICATIONS (WINDOWS)

HARDWARE

• 2GB total RAM (4GB recommended)

• 2GB hard disk space for program files and enough hard disk space to store checked-out assets

• 32-bit or 64-bit

SOFTWARE

• Microsoft Windows Windows 7 SP1 (Business or Ultimate Edition), Windows 8 or Windows

LANGUAGES

• Front-End: C#

• Back-End: Hsql

SUPPORTED PLATFORMS

• Intel Core 2 Duo processor running Windows 7 (32 & 64 Bit), Windows 8 (32 & 64 Bit) or Windows 8.1 (32 & 64 Bit)

• Intel Xeon processor running Windows 7 (32 & 64 Bit), Windows 8 (32 & 64 Bit) or Windows 8.1 (32 & 64 Bit)

• Intel vPro technology and Intel Core 2 Duo running Windows 7 (32 & 64 Bit), Windows 8 (32 & 64 Bit) or Windows 8.1 (32 & 64 Bit)

• Intel Pentium 4 processor running Windows 7 (32 & 64 Bit), Windows 8 (32 & 64 Bit) or Windows 8.1 (32 & 64 Bit)

QUARK PUBLISHING PLATFORM DATABASE

• HSQL DB 1.8 in embedded mode (The Quark Publishing Platform Server installer installs this database in embedded mode if you choose HSQL DB during installation. This database is recommended only for development, and is not recommended for production environments.)

• Microsoft SQL Server 2008 R2 (Standard Edition or Enterprise Edition) or Microsoft SQL Server 2012 (Standard Edition or Enterprise Edition)

• Oracle Database 11gR2 on Red Hat Enterprise Linux 5 or Microsoft Windows Server 2003

References

· Github.com

· Microsoft.com

· uiautomationverify.codeplex.com

· teststack.azurewebsites.net

· blogs.msdn.com

· www.codeproject.com

· www.quark.com

· asp.net