Wednesday, July 23, 2014

Keyword Driven Framework - CodedUI

We can maintain actions (click, set etc.), keywords and object repository in excel sheet.  Below is a sample:


Now, create a class file in CodedUI test project and implement the logic for reading excel sheet and initializing variables. Distinguish the type of test control (HtmlEdit, HtmlHyperlink etc.) based on the Controltype and assign properties to the test control.

Friday, June 7, 2013

Executing CodedUI tests on Firefox and CodedUI



  • Install Visual Studio 2012 Ultimate version
  • Install Visual Studio 2012 update 2
  • Download Selenium components for CodedUI cross browser testing from http://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d
  • Download Chrome driver and Selenium dot net bindings from the above link and plac them under  "%ProgramFiles%\Common files\microsoft shared\VSTT\Cross Browser Selenium Components"
  • Create a CodedUI test by recording actions on IE browser
  • In CodedUI test class, add the property BrowserWindow.CurrentBrowser = "Firefox" (for chrome browser it is "Chrome")
  • Run the tests
  • If you get 'Playback engine could not find Selenium binaries', create an empty 'castle.core.dll' under "..\microsoft shared\VSTT\Cross Browser Selenium Components" folder
  • Re-run the tests

Wednesday, July 13, 2011

CodedUI Automation tool

Coded UI is an UI test automation tool provided in Visual Studio 2010. Below are the features:
v   Record and Playback support
v   Generated code can be customized
v   Data parameterization (Data driven approach)
v   Assertions (similar to checkpoints in QTP)
v   Object synchronization (‘Wait’ statements)
v   Execute or run the automated tests
v   No built-in mechanism for handling events like unexpected dialogs
After recording a scenario, the following files will be added to the CodedUI project:

File
Description
Editable ?
CodedUITest1.cs
The default name for the file is CodedUITest1.cs. This is the file in which all the Test Methods are added
Yes
UIMap.uitest
An XML file has all the information about the recording including actions, objects and data.
NO (In future, MS may have editor for this file)
UIMap.Designer.cs
This file contains the code generated by the tool based on the recording in UIMap.uitest file (a.k.a. code behind file).
NO. Any edits to this will be lost
UIMap.cs
The main class generated by the tool is UIMap. This is partial class and is split into ‘UIMap.Designer.cs’  and ‘UIMap.cs’. While UIMap.Designer.cs contains code generated by the tool and should not be edited, the UIMap.cs file is the place where you would place all your customization
YES


The following assemblies are added as reference to the CodedUI project: 
v   Microsoft.VisualStudio.TestTools.UITesting (ApplicationUnderTest, BrowserWindow, Keyboard, Mouse, PlayBack, ControlType, UITestControl, etc.)
v   Microsoft.VisualStudio.TestTools.UnitTesting (Assert, StringAssert, Collection Assert)
v   Scenario to record: Browse google, search for a company and    ensure that company name and it’s URL is present in the first link
v   Microsoft.VisualStudio.TestTools.UITest.Common
v   Microsoft.VisualStudio.TestTools.UITest.Extension