Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Showing posts with label uimap. Show all posts
Showing posts with label uimap. Show all posts

Add Objects In uimap.uitest file in the CodedUi Control map file

How to add objects in the uimap.uitest that is the CodedUi Control map file ?
        Do you actually know how the automation testing proceeds in a tool. It is very simple, we store the object's properties in some repository files and as and when we need to do some operation on those objects we identify those objects using some logical names that we might choose on our own and then call specific events such as click events to do the required operation.

 For example we might have a sign out link available in the website and our sole aim is to click the sign out link.

The way we can proceed is two:
1. It is simple record and playback approach and parameterise any data that has been making the sign out link dependent on the logged in user.
2. Just add the respective object in the repository file in coded ui testing it is the uimap file. Then call the mouse.click event on that particular object that is sign out object.

Now suppose the added object is sign out link we will be having below outlined methodology.
Declare the object with its particular hierarchy order and then call mouse.click event.

HtmlControl uiSignOutLink = this.UIMap.HierarchyWindow.HierarchyFrame.uiSgnOutlink;
Mouse.click(uiSignOutLink , new POint(0,0)); 


The above method signifies the syntax associated with the Mouse.click event.
The first parameter it takes is an object as has been declared in a line above and the second paramater it takes is a sort of syntax that needs to be cared for , do remain informed that the co-ordinates are no way deciding the object recognition, so it is immaterial whetehre we keep co-ordinates as 0,0 or some other as 56,67.

In the below screenshots, I have outlined some of the process to be followed to get the particular object added into the Uimap file that is the object repository file of the CodeduiTest project.

In the below sequence we will add an object using uitest control of the recording window.

Planning to add the tag of the blog : "Automation Testing On Share" into the uitest control map file .
So what I have just done is drag the cross hair which we use for inserting assertion points onto the psecific object by highlighting it as is shown below .
Now just open up the closed arrow sequence to get the object hierarchy established and understood by us and also find the options of adding the object into the Test Project's specific control map file.We can see the Add object button which we need to click and the object that has been in ticked status will be hence added to our control map file.


We can then find the message at the bottom that the object has been added successfully into the uimap file.

So guys whatever we have done till now has been in the IDE's buffer only, we need to store it into the uimap file and hence need to generate code for the object's addition into the uimap file for all our future access of the objects and perform relevant operations on the same. Hence we are needed to click Generate Code button.


The code is being generated now.

Okay so this is how we have learnt to add objects onto our object repository in the VSTS CodedUi Test Project automation tetsing.
I know this might just seem to be a bit complex in intial phase but once you can catch onto what has been outlined above, the usage can be really awesome and the code rework that we generally do in our automation script run during the regression suite execution can be made very easy.

A $25 tool has so much in offering I never could have thought of but the way this tool's utilisation has been encashed upon  by us in our team, I think the day is not far off , when the VSTS Test Projects might just be the most sought after automation tool in the industry .



For more on Automation Testing using CodedUitesting in VSTS :Log On To

Automation Testing Using Coded Ui Testing In VSTS

Multiple UiTest Files in VSTS CodedUi Testing

How to create Multiple UiTset files in a  CodedUi Test Project?

 The logically inter related blocks of modules within a System Under Test can be automated in a modularized  block of code, in the following outlined manner. for our case we will just have a look at how we have create three different Uitest files. 

The first UiTest file is AllLink.uitest file, which is actually a xml file, and its two components are namely , AllLink.cs and AllLink.designer.cs file. The designer file is non editable file which incorporates all the recorded set of scripts in it. The AllLink.cs file is again a partial class file which is used for more of data overriding and code globalisation along with reusability.

The second UiTest file is UsrIntrfc.uitest file, which is actually a xml file, and its two components are namely ,  UsrIntrfc.cs and  UsrIntrfc.designer.cs file. The designer file is non editable file which incorporates all the recorded set of scripts in it. The  UsrIntrfc.cs file is again a partial class file which is used for more of data overriding and code globalisation along with reusability.


The third  UiTest file is MsgValidatn.uitest file, which is actually a xml file, and its two components are namely ,  MsgValidatn.cs and  MsgValidatn.designer.cs file. The designer file is non editable file which incorporates all the recorded set of scripts in it. The  MsgValidatn.cs file is again a partial class file which is used for more of data overriding and code globalisation along with reusability.

The approach for recording the various functions outlined as under has thus been classified into three specific categories, namely clicking the links, doing the functional event, and finally validating the final event of functionality being successful.

The AllLink uitest file is actually an xml file having the events related to clicking the links, similarly UsrIntrfc is the functional event, MsgValdtn is the validation checkpoint also called the assertion point in VSTS as termed in QTP automation.

At last we have  one class file wherein , we will bring into use all three events from three uitest files and create a standard framework for automating with minimal rework effort.
Just have a look at the snapshot below to gain insights into how we arrange the multiple uitst files :

As outlined in the code below, we create an instance of all three uitest files, and utilize the features available as per the record time in them.

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
using multipleuimaps.Uimaps.AllLinkClasses;
using multipleuimaps.UIAssertions.UsrIntrfcClasses;
using multipleuimaps.MsgValdtn.MsgValdtnClasses;

namespace multipleuimaps.Uimaps.AllLinkClasses
{
    ///


    /// Summary description for CodedUITest1
    ///
    [CodedUITest]
    public class UploadValidation
    {
        public UploadValidation()
        {
        }

        [TestMethod]
        public void UploadValidationTestMethod1()
        {
            // 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

            this.AllLink.ClkDocLink();
            this.UsrIntrfc.FeatrUploadDoc();
            this.MsgValdtn.ScsfulyUplodedDoc();
            //this.AllLink.ClkDocMyHomeLnk();
            //this.AllLink.ClkDocAdminLnk();
            //this.AllLink.ClkDocAdminPrmsnLnk();
            //this.AllLink.ClkDocAdminFltrLnk();
            //this.AllLink.ClkDocAdminCreateRepLnk();
            //this.AllLink.ClkDocAdminEditRepLnk();

        }

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:

        ////Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{       
        //    // 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
        //}

        ////Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{       
        //    // 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
        //}

        #endregion

        ///


        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        private TestContext testContextInstance;


        // References made to each of the three uitest files :
        // AllLnk
        // UsrIntrfc
        //MsgValdtn

        public multipleuimaps.MsgValdtn.MsgValdtnClasses.MsgValdtn MsgValdtn
        {
            get
            {
                if ((this.map2 == null))
                {
                    this.map2 = new multipleuimaps.MsgValdtn.MsgValdtnClasses.MsgValdtn();
                }

                return this.map2;
            }
        }

        private multipleuimaps.MsgValdtn.MsgValdtnClasses.MsgValdtn map2;

       public AllLink AllLink
        {
            get
            {
                if ((this.map1 == null))
                {
                    this.map1 = new AllLink();
                }

                return this.map1;
            }
        }

        private AllLink map1;

        public UsrIntrfc UsrIntrfc
        {
            get
            {
                if ((this.map == null))
                {
                    this.map = new UsrIntrfc();
                }

                return this.map;
            }
        }

        private UsrIntrfc map;


    }
}

UiMap.cs File In Coded Ui Testing In VSTS

UiMap.cs File In Coded Ui Testing In VSTS
What is : UiMap.cs file is a partial class file in the Coded UI Testing approach used in the VSTS.

The general perception that a Automation Testing concept involves is the possibility of incorporating a framework approach on the top of any automation tool. This very class file which is a partial class file can be used to serve the same purpose in VSTS Automation Testing.

This is the one single place wherein  we can build the utility functions that can be used across the application by the Automation Test Class files : which are none other than the Coded UI Class files. Also from here we can even override the properties of the objects available in the application  as per the recorded scripts. At times we even refer the UIMap.cs files as the extensions for the uimap.designer.cs files. The only difference between the two being the Former one is editable while the latter is not editable at all. The latter one's editable fetaure is availed by overriding the objects porperties.

Partial class files are in genuine a file which has some reusable code blocks that act as a continuance to some other class files. In our case it is the designer file that is the class file and the uimap.cs file is the continuance to it. Generally some very raw features such as  a link click or a URL load, or some other sceraios where in the Robustness of a Uimap.Cs partial class file can be brought to use is when we have multiple types of users who can log into an application and it is the role based authorization that is provided after having been authenticated to be a valid user in the application, we bring this very partial class to an optimum use.

We may record a scenario for the features of an application wherein the access to various sub - features may be on the basis of  roles provided , so by the usage of some Switch case from within the partial class files, we can attain the flexibility of code once reuse everywhere.

A small code to simulate the behavior is shown for reference to illustrate the usage of the UImap.cs partial class file:

By this block of code what we can do is call the login function with Two parameters, one being the Testcontext and the other one being the Role. depending on the role the specific authorized user can log inot the application. We have genuinely considered some eight sets of users, however  any programmar can guess that it remains a valid intelligence to use it as per our requirements.

Do have a look at the code below :