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 CodedUi Testing. Show all posts
Showing posts with label CodedUi Testing. Show all posts

Modular approach in Coded UI Testing

Coded Ui Testing is not a very simple Automation Testing Approach and the challenges that come across while we approach the same is even more complex. The very recent issue we have come across is some Script Maintenance in the Coded UI Test files that have been executed to generate some positive ROI in the very near future.

Coded Ui Test generation is a very simple Automation testing technique with lots of support available in the internet.
  • Keep all the code blocks modular, small, simple.
    Codes must not be having more than any one function flow such as create a mail account.
  • When putting any validations as Verification or assertion points, avoid using multiple in one function block.
  • There might be some code flow alteration in the Navigation path of the application, hence the Navigation flow code script must be free from the functional flow points.
  • Uimap.cs File is a Partial class file that can be used to an optimal extent by bringing in the feature of code Reusability and hence a lot more script maintenance ease.
  • Do keep in mind that the UImap.cs codes must not have any dependence on any script block that might be brought to any us.
  • When we enter the Script maintenance phase do not recode anything from fresh , just avoid re recording, and prefer  Code customization along with the partial class file.
Inspite of all this norms if at all the script maintenance is a seemingly big risk to proceed with, adopt some framework, such as complete customized approach for all possible event driven activities, such as a single function block that can handle all types of button clicks. A single function block that can handle all types of link click.

However this type of approach has lost its relevance as in the current Automation Scenario, we aim to generate some quick ROI rather than depending on the old outdated Regression based script execution to be processed upon to meet some ROI.

Coded UI Automation Testing: Functional Automation In VSTS2010

How to do Automation Testing Using Coded Ui Testing :
Once we are done with the recording of our navigation and doing some functional activity like logging into the gmail account or any other such event and wish to now view the code for the recording that sax been carried out, we can stop recording. Now suppose the same is to be done , just click on the last button within the small window in the right hand side corner in the below side of the computer screen.

Just click on the last button which has the word “Generate code” subscribed on it. Clicking this very button results all the UI activity getting coded down into C# scripts. This very language is in toto dependent on the type of language selected during the project creation window.  Clicking of this very Button opens up another pop up which has in it the field for writing the name of the coded scripts which in turn is modularized under the same function name . Now we are having a modularized functional block which does the complete activity that we had performed during the Recording time [here being the Logging into the Gmail Account]. Suppose we give the same function name as LogIntoGmail.
Now just close the record phase by clicking on the close button within the small pop up [i:e Record pop up]. The IDE of VSTS opens up within which we have the CodedUiTest file availed with the default name being the CodedUITest1.cs as can be seen in the Solution Explorer window .  Depending on the naming conventions we can just we may rename this very file as in this case can be “LogIntoGmail_Class_CUI.cs”.
After having renamed this the reference needs to be updated which is done automatically by the editor itself after clicking the confirmation option as asked by the same. Now just double click the CodedUI class file.  Within, the class file – a constructor is availed having the same name as is the name of the CodedUITest Fie in this case being : “LogIntoGmail_Class_CUI.cs”.  After delving into the class block we can find a yet another function name : LogIntoGmail. This name is the same as was the functiona name provided by us during the Add generate code button click.  The function call is only available here , so where is the code for the recordings we performed. Well the same can be discussed in some other columns , however for now what we can do is  keep this as taken for granted that in our project in which ever Coded UI Test Class file  we paste this very function call , and run the code, we will get the Playback for all the steps that we recorded.
I hope I am pretty lucid when I say this , to be more clear  just go into the Solution explorer and Right Click on the Project Name Which is already created by you , add another CodedUi Test File , and give its name as  “LogIntoGmail_Replica_Class_CUI.cs”. Now just double click the class file and under the constructor write a function call for the same set of playback as was achieved by the Previous recording by writing :  LogIntoGmail.   

 What will this do for us , Well a lot of Reusability cann be availed by this very functionality.  Now we have two Coded Ui Class files namely : LogIntoGmail_Class_CUI.cs & LogIntoGmail_Replica_Class_CUI.cs . Now save the complete Test Project  and plan for running your Automation Scripts. For the same purpose we can go into the Tools Menu and under it Window Menu – Go For Test View . This is actually the view which has in it the Various Class file names availed. Give a refresh to the Test View screen, we get the two class files names coming up in the same. Now , of the items available we can see two listed as : Run the first one LogIntoGmail_Class_CUI by clicking the same and giving a run button click. The recorded scenario will be played back . Now, Run the first one LogIntoGmail_Replica _Class_CUI by clicking the same and giving a run button click. The recorded scenario will be played back . This shows the Code Reusability. Will Take this to next level in future posts..



Coded UI Test Automation : Functional Automation In VSTS2010

VSTS 2010 has the Coded Ui Feature that is going to be heavily impinging on the Website related Test automation project dependency on several of the highly costly tools such as QTP RFT et al in near future.
The Coded Ui feature shall be demonstrated hitherto because it has been successfully used by the team across location to automate around 1200 oddd Test Scenarios at a pretty brisk pace.
How to Initiate ?
The Test project is what we select for creating an automation project under the Test project Template using
the coding language as of our choice ranging from  C# to VB through VC++ depending on the resource expertise availability.

Now creation of a Test Project results in a specific folder hierarchy that intricacies will be dealt separately .
But the point of immediate concern will be the roadmap to the creation of the complete basic functional test Automation
which is nothing but a demo with some screenshots organised in a step by step manner so as to let a layman can  proceed with the Test Automation getting realised to a success. The same shall be addressed in my next couple of posts.

Coded UI Advantage ?
 
The very basic issue that my experience with QTP automation suggests is the dependency on the hierarchy that
guides the compelete object Recognitiion mechanism in the QTP. This is a very organised manner of recognising the
various objects according to their Control Ids along with the Object Hierarchy which we at a very basic level relate
something as 
Browser-> Page-> Object controls and bla bla bla....

This results in some of the constraints related to further changes in the application that might result in the future
object recognition of the same control with some added prefix controls. One issue that I came across in this context that I would definitely like to share across is the incorportaion of the frame within the page that results in further object recognition of the same very control having the erstwhile control id in the hierarchial order of

Browser-> Page-> Frame.  
This is where I guess the QTP object recognition has faltered to address to the business needs.
And this simple loophole causes tremendously to the overall run of the scripts in the builds availed.

 
Near future might just carve out a niche for the new tool Coded UI Test Automation from the hubs of Microsoft development team capitalising onto the Market share of the most of the other Functional Test Automation Tool.

Hierarchy of Code creation during record time by Coded UI Approach ?

We can definitely take a lot more than just one or two posts discussing the overall hierarchy followed by the VSTS tool at a macro level. While creating the Test Project  under the Predefined templates by selecting the Test Project we move into a new view of the complete solution that   gets generated in VSTS. Namely the Solution Explorer. However if the same is not available do kindly click the View tab and select the Solution Explorer. It gets automatically hooked up onto the left pane of the window.

  • Suppose the name of the project is CodedUIDemo, the same name comes up under the complete hierarchy of the Test Project.
  • Now just right click the project name and click Add a Coded UI test to the project.
  • Wait for sometime , have a Kitkat break and come back.
  • I said the above for those having their RAM lesser than 2 GB.
  • Jokes apart , something that can be figured up from here is a small  "User Interface" comes as  a pop-Up in the right corner at the bottom.
  • Do note that there is  red button in the left side of the small sleek UI .
  • That very button when clicked provides the start to the Record Feature of the Coded UI Test Automation predominantly for the Functional Testing.
  • Other than this button we have three more featured buttons with some exciting functionality , but lets prefer going slow.
  • Until the red button is clicked , nothing gets recorded, but once you click this very red button, every action starts recorded.
  • Lets not be worried about every action getting recorded as it is pretty headache creating stuff.
  • Are you imagining the scenario like you are in the middle of doing some recording and the Chat window popping up and you getting excited your friend's chat interests more than the record you are in the middle of.
  • But take a chill - pill and do click the same button you had clicked to start recording which is currently displayed not as a red button but as a ..........
  • As a Window Media Player's "PAUSE" Button.
  • Just click the pause button and reply to the friend's chat message instantly congratulating him for his marriage getting fixed up with the lady he loves....
  • Dudes my lady love is in from work ..Lets carry on with this Interaction again with the following Posts.

Till then Hum hain rahi pyaar k fir milenge chalte chalte....