Issues in Visual Studio Coded ui Automation Testing

I received a mail from one of my colleagues in the automation testing arena who is using Coded Ui test project of the Visual Studio to automate some features. Below is the mail I recieved, and I shall be replying to the issues specified here itslef, so that the more audience can acquaint themselves with this issues in Coded Ui automation.


Mail :
Hi Viplav,
I am using VSTS2010 for automating a search functionality in my application. I recorded three coded UI test for-

a) Login- CodedUItest
b) Policy Search using some search criteria & then editing a policy selecting from search results- CodedUItest
c) Logout- CodedUItest


Thereafter I called login & logout functions from Search codedUITest.cs

I also have parameterized search criteria values (PolicyNumber, Policystatus etc) from  excel sheet (Used AppConfig for excel data connection).
I have 4 data rows in my input data sheet (to parameterize search criteria at the rum time).
Issue 1- Now what is Currently happening is- That my coded UITest runs , it does login, perform policy search and edit policy & then gets logout for each and every interation i.e for each data row, causing Opening of multiple browser instances.

My expectation :
            What I want to implement is just one login & one logout. So that- 
            a)users logins
            b)Perform search for all iterations, edit policy
            c)Go back to main page, Repeat steps a-c for all iterations
            d) then log out

Comments : A very geniuinely valid point raised by you Mahesh. Would definitely provide resolution to the same.


Issue2-  The second issue happening with all the iterations is that even after my script has executed for all data rows,It keeps on running and opening browser instances taking parametrized values as blank.
My expectation :
            Ideally it should stops once test is executed for all data rows, When it found no search criteria that is empty cells it should stop running.
            Here i need help, If we can implement some End of Row (EOR) in scripts, As soon as scripts finds EOR it should stop execution.
Comments : Would definitely provide its resolution.

Issue 3-
This issue is related to issue 3, as multiple browser instances are opening. I need some way to close them as soon as test completes for all iterations, better if they get closed after every iteration. I know we can use KILL IE function but I have to give control back to the interface where from I have invoked the scripts that is opened in IE browser. If I apply Kill IE function after all iterations are done, Interface brwoser gets closed as well.

Need you support in all this issues. Please guide.
I really appreciate any help in this regard.

Regards,
Mahendra.

Hi Mahendra,

I would be giving resolution to these three issues in the below comment chain one at a time. Do stay posted.

- Viplav Anand

The better approach is available here to address the business scenario handling :http://www.articlesontesting.com/2011/07/multiple-iteration-data-driven-code-ui.html

8 comments:

  1. Hi Viplav,

    Adding one more issue..Please spare your time to resolve this one as well.
    ----------------------------
    Issue #4 Need to know how to use the below mentioned function-

    foreach (System.Data.DataRow dr in Dataset1.Tables["MLSData"].Rows)

    I want my script to read data from excel only for the rows having data, for example-
    Iteration 1- Row1
    Iteration 2- Row2

    Row 3 is blank. Script should not execute for row 3.

    Or if we can match a string in row3 for example "End of Record" in the very first column of row 3. So that when script read this it should stop saying end of records.

    Currently it is executing even for the blank rows.

    is it possible to do through testcontext.


    Thanks

    ReplyDelete
  2. Hi Viplav..Waiting for ur replies on above mentioned issue.

    ReplyDelete
  3. Mahendra : yeah we have a resolution for the same. I will share with you the solution by tomorrow evening for sure.

    ReplyDelete
  4. Hi Mahendra,
    As responded to your mail, the approach of this set of isssues is usage of the Ordered test within the test project you have created. In your Test project which currently comprises of three Coded Ui class files, add an ordered test . Within that veryu ordered test put the three coded ui class files in the order as it is expected to execute. In this case being the Login, then policy then log out. Also as a part of simple practice to keep the test project easy to maintain, have class file dependent data files in csv format. Onwe file for the login details class file, and it to the login coded ui test file through its test view. Add another csv file with the data set as is required, and attach it to the policy class file. .
    Just execute the ordered test to run your business scenario and get the ROI generated in an easy to manage scripting approach as provided with Visual studio test project feature.

    ReplyDelete
  5. For more on using Ordered Test feature log on to http://www.articlesontesting.com/2011/06/ordered-test-in-vsts.html

    Regarding last issue of browser killing, i need more clarification if you can share.

    ReplyDelete
  6. http://www.articlesontesting.com/2011/07/multiple-iteration-data-driven-code-ui.html

    The resolution steps are provided at above url.

    ReplyDelete
  7. Regarding first issue, I figured out much simpler solution:
    I divided the code to preparation part (in your case login) and test part.
    So login part runs only while first row of the data supplied. Code looks like this:

    int run = TestContext.DataRow.Table.Rows.IndexOf(TestContext.DataRow);

    if (run == 0)
    {
    open browser
    login
    }

    ReplyDelete
  8. Hi Spartak, Good to have your knowledge shared across all of us, but if we have lots of data dependencies, and we wish to design a robust framework, this might result into performance issues.However the approach can definitely be explored for more robustness in this way.I would definitely give a try to this.

    ReplyDelete