• Home
  • About
  • BestBloggingIdeas
  • DotNetLearningSource
  • FORUM
  • Joblinks
  • Latest News
  • Policy
  • POSTS
  • SimplySqlServer.Com && SimplyAspDotNet.Com
  • Sitemap

Join Ours Forum

Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

RSS Feed
  • Bounty Huge Roll [Amazon Frustration-Free Packaging]
  • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
  • The Basic Overview of Windows Mobile Development Asp.Net C#
  • Overview of Sql server extended properties Asp.Net C#
  • How to Use Sql Server Extended properties using visual studio Asp.Net C#
  • Adobe Dreamweaver Templates Accelerate Web Development
  • Top Tips for Web Design Projects
  • How to Achieve a Good Web Design Structure
  • To Use Or Not To Use Website Templates
  • Five Tips to a Successful Website
  • Top 10 Articles,


    Silverlight Datagrid Select Update Delete Insert Asp.Net C#

    Differences Similarities Benefits Between Typed Datasets and Untyped Datasets asp.net c#

    Linq to Sql Introduction Entities Ado.Net C# SqlClasses Attributes Linq Mapping

    Linq Programming/How Linq Works?/Linq Implementation In Asp.Net C# Ado.Net

    Performing Developing Using Investigating Asp.Net 2.0 Ajax Application Development Asp.Net C#

    Hosting/Install Wcf Services in a Windows Service Asp.Net C#

    Connecting Silverlight to Wcf Asp.Net C#

    Silverlight Data Grid Data Binding WCF Asp.Net C#

    Invoking/Accessing/Calling WCF Service Without Adding/Creating Proxy/Reference Asp.Net C#

    Performing Doing Creating Insert Update Delete sql data Using Linq Database Asp.Net C#

    Performing Developing Creating Asp.Net 4.0 Test Project/UI Testing C# 4.0 Visual Studio 2010

    Posted by james on March 4, 2011 Leave a comment (0) Go to comments

    Introduction:


    In this article i am going to expain about how to perform test project in asp.net 4.0 and above versions.


    Main:


    Please install asp.net 3.5 and above version,


    Demo:
    1.       Open Visual Studio 2010 and create a new Test Project.



    2.       Add a new CodedUI Test and click on OK button.



    A new window gets opened for selecting how do you want to create your coded UI test.



    “Record actions edit UI map or add assertions” option allows you to do the recording on your application      and then generates code for the recording. “Use an existing action recording” allows the code generation for already recorded action. 3. Select the first option “Record actions edit UI map or add assertions”. It will open the Coded UI Test builder for creating the recording.



    Click on the left most red button for recording, the icon will change to pause/stop button as shown below.



    4. Perform all the operations on your application which you want to record. As a sample I am recording the steps of searching for Visual Studio 2010 in Bing web site. 

                                                       
    5. Once you are done with recording, press stop button (left most). 


            


      
    And then click on Generate code button (right most). 
               
    Provide appropriate name for the generated method and click on Add and Generate button.
    6. If you want to add some assertion on some control’s property or you want to rename the objects, click on   the cross hair (second last button) present just left to Generate code button. 
            
    It will show the object hierarchy in the left pane as below and the properties of the selected object in right pane. 
            

    You can click on Add Assertion button to create an assertion for the selected control’s selected property.
    See below the list of possible assertions: 


         


    Create the assertion and again click on Generate Code button which will pop up a window to provide the Method Name, give appropriate name and generate the code for the created assertion. 


      

    7.       Now open the UIMap.Designer.cs file and see the code generated by Coded UI for you. 


    ///


    /// RecordedMethod3 – Use ‘RecordedMethod3Params’ to pass parameters into this method.


    ///


    public void RecordedMethod1()


    {




    #region Variable Declarations


    HtmlEdit uIEnteryoursearchtermEdit = this.UIExercise3DataDrivenDWindow.UIBingDocument.UIEnteryoursearchtermEdit;


    HtmlDiv uIItemPane = this.UIExercise3DataDrivenDWindow.UIBingDocument.UISb_formCustom.UIItemPane;


    HtmlInputButton uISearchButton = this.UIExercise3DataDrivenDWindow.UIBingDocument.UISearchButton;


    WinButton uICloseButton = this.UIExercise3DataDrivenDWindow.UIVisualstudio2010BingTitleBar.UICloseButton;


    #endregion


    // Go to web page ‘http://www.bing.com/’ using new browser instance


    this.UIExercise3DataDrivenDWindow.LaunchUrl(new System.Uri(this.RecordedMethod3Params.UIExercise3DataDrivenDWindowUrl));


    // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)


    Playback.PlaybackSettings.ContinueOnError = true;


    // Mouse hover ‘Enter your search term’ text box at (213, 5)


    Mouse.Hover(uIEnteryoursearchtermEdit, new Point(213, 5));


    // Reset flag to ensure that play back stops if there is an error.


    Playback.PlaybackSettings.ContinueOnError = false;


    // Click ‘Unknown Name’ pane


    Mouse.Click(uIItemPane, new Point(151, 34));


    // Type ‘visual studio 2010′ in ‘Unknown Name’ pane


    Keyboard.SendKeys(uIItemPane, this.RecordedMethod3Params.UIItemPaneSendKeys, ModifierKeys.None);


    // Type ‘visual studio2010′ in ‘Enter your search term’ text box


    uIEnteryoursearchtermEdit.Text = this.RecordedMethod3Params.UIEnteryoursearchtermEditText;


    // Click ‘Search’ button


    Mouse.Click(uISearchButton, new Point(21, 20));


    // Click ‘Close’ button


    Mouse.Click(uICloseButton, new Point(18, 8));


    }



    8. See the code generated by Coded UI in “CodedUITestMethod1”



    [TestMethod]


    public void CodedUITestMethod1()


    {



    this.UIMap.RecordedMethod1();


    // To generate code for this test, select “Generate Code for Coded UI Test” from the shortcut menu and select one of the menu items.


    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463


    }




    Open the Test List Editor (Test -> Windows ->Test list Editor) and run the ‘CodedUITestMethod1” present in CodedUITest.cs file.



      


    Coded UI maintains a specific file structure as follows:

    ·         CodedUITest.cs  file

    ·         UIMap.uitest file

    ·         UIMap.Designer.cs file

    ·         UIMap.cs file





    CodedUITest.cs file: 
    CodedUITest.cs file is a unit test file having TestClass decorated with [CodedUITest] attribute and contains multiple methods decorated with [TestMethod] attribute.



    UIMap.uitest file:
    UIMap.uitest is an xml file containing all the windows, controls, properties, methods, actions and assertions etc used for playback.



    UIMap.Designer.cs file:
    UIMap.Designer.cs file is a partial class which contains the classes for various controls and their fields, properties and methods.



    UIMap.cs file:
    UIMap.cs is also a partial class of UIMap.Designer.cs. It can contain all the recorded methods which need customization. 

    Coded UI provides an easy to use graphical way to write the test automation. User can also write his own custom code leveraging all .Net features instead of going with coded ui generated code. We will discuss about working with custom code in my next article.


    Conclusion:


    Hope this helps,happy coding


    References:


    msdn.microsoft.com

    ASP.NETBasic, Coded, Walkthrough
    ← What is/Explain Named and Optional Parameters in C# Asp.Net C# 4.0
    Differences Similarities between Web Server and Application server iplanet Websphere Java →

    Learn Easily Using Video Tutorials


    How to choose the right Java IDE – explained Eclipse NetBeans BlueJ

    Developing/Creating/Performing/Configuring Java Applications Using Eclipse IDE

    Step By Step Guide for Download/Install Configure Eclipse IDE for Java

    Editing data with the GridView control Asp.Net C#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Best way to prepare asp.net Interview - Success Stories

    Download Important Questions and PPT's:

    Sql Server Important Questions Online free download

    Dotnet Important Questions Online free download

    Exploring Linq to Sql Process Flow

    Learn how to perform silverlight programming

    Learn OOPs concepts in better and well manner

    Learn Ajax in better and well manner

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    *


    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Enter your email address:

    Delivered by FeedBurner

    • Recent Posts

      • Bounty Huge Roll [Amazon Frustration-Free Packaging]
      • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
      • The Basic Overview of Windows Mobile Development Asp.Net C#
      • Overview of Sql server extended properties Asp.Net C#
      • How to Use Sql Server Extended properties using visual studio Asp.Net C#
    • Search by Tags!

      Application AspNet Basic between Black Bluetooth Build Business Collection Consultants Design Development Downloading effective Excel Experts Generics Implement Installing Interview Logic Management Microsoft Minutes Object Outlook Professional Programmer Programming Project Projects Questions Ready Select Server Services Silverlight Source Strings Studio Through using Visual Website Wordpress
    • Archives

      • August 2011
      • June 2011
      • May 2011
      • April 2011
      • March 2011
      • February 2011
      • December 2010
      • November 2010
      • October 2010
      • September 2010
      • August 2010
      • July 2010
      • June 2010
      • May 2010
      • April 2010
      • March 2010
      • February 2010
      • January 2010
      • December 2009
      • November 2009
      • October 2009
      • September 2009

    Copyright © 2012 NetProgrammingHelp.com

    Δ Top