Coded UI

Coded UI is a UI testing framework.

Prerequisites for Coded UI :

Visual Studio 2012 or Visual Studio 2010 Premium or Ultimate. Incase you have not installed full versions of the Visual Studio 2010, install feature pack 2 for Visual Studio from here. http://msdn.microsoft.com/en-us/library/gg269474%28v=vs.100%29.aspx

What can you do with Coded UI ?

diagram1

Demo : Testing Bing using Coded UI.

Open Visual Studio 2012. After installation you will see Coded UI Test project template in Test.

diagram2

Select the first option to record.

diagram3
The panel below has 4 options :

1) Record actions 2) Show Recorded Steps 3) Add Assertions 4) Generate Code .

diagram4

Open browser and type bing.com/ and click record.

Steps to record :
1) Type Visual Studio 2010 in the search box.
2) Click Search.
3) Click on back button of browser. Run the tests.
NOTE: While running the tests , the state of UI has to be same as and when recorded, so that the running test can locate the search box and execute tests.Else tests might fail.

diagram6
Below is the project structure.
CodedUITest1.cs – code for running tests.
UIMap.uitest – xml file which records actions on user interface.testprojectstructure

Making your UI Test Data Driven.
Open Excel and enter data for your search list.
Save it as Data.csv. Add Data.csv to your project. Set its properties. Set Build Action to Content and Copy to Output Directory to Copy Always.

datacsv
Add the attribute above your test method to take input values from the Data.csv file .datasource

To take data from excel sheet , you will have to set the parameters as below.

[DeploymentItem("Data.csv"),DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV",
"|DataDirectory|\\Data.csv", "Data#csv",
DataAccessMethod.Sequential),TestMethod]
public void CodedUITestMethod1()
{
this.UIMap.TestBingParams.UIEnteryoursearchtermEditText = TestContext.DataRow["SearchText"].ToString();
this.UIMap.TestBing();
}

Run your tests. There you have data driven tests for Bing UI. Your search will be done for all the inputs.

About these ads
Posted in Uncategorized. Leave a Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 36 other followers