In this post we will discuss working with Drawhighlight method as well as diagnostics in Coded UI testing to generate HTML report as shown below.
Visual debug during playback
- In coded UI testing we can set the diagnostics information for our code and we can get more information about the underlying code execution.
- This we can obtain using a method called DrawHighlight
- This will show a rectangular red color box in the control.
Problem with DrawHighlight()
- The DrawHighlight() method is, it takes 7 seconds to complete its action, which incurs a slow performance over the period of time in you code execution.
- And hence considered as a bad practice.
In previous post, we discussed how to
- Design our custom library,
- Reading and parsing data using ExcelDataReader and
- Converting the data into Data Table.
In this part, we will discuss storing the data into a collection and then read data for our test method from the collection.
Why use Collection?
Well, reading data just once from external data source like Excel sheet and storing the data in-memory like collections, will improve the performance tremendously as opposed to reading data each and every time from external data source like excel, since this will affect the performance of our test script. Read more
We have already discussed Data Driven Testing in Coded UI with CSV in previous post. In previous post we decorated our test method with [DataSource] attribute and used TestContext.DataRow method to read data out from CSV file.
But there are some limitation while using DataSource attribute like
- We don’t have control over the iteration (via code, but we can do via properties)
- We cannot be very precise about which column and row data we need
Custom data driven library for excel
Hence to overcome to shortcoming of DataSource attribute, we are going to design our own custom data driven library for excel, As always, before starting to create any custom library, it’s always a good practice to first create a design before writing code. Our design looks something like this
Reading and parsing data from excel
We all know using Visual Studio 2013 we can do automated UI testing for Windows Mobile application (built using XAML) with Coded UI , but recently Xamarin, which is well known for developing Android and IOS native application development using Visual Studio platform has released a new API called Xamarin.UITest, which will enable automation testing of Android and IOS native application.
Well, if you are new to Xamarin, then you are very late to know about this information, since Microsoft is hugely supporting Xamarin for developing android and IOS application development using its most famous productivity tool visual studio as shown below (screenshot from Xamarin.com)
Setting up test ready Android and IOS application
In this post we will discuss working with different browser in Coded UI Testing such as Chrome, firefox and IE using the same code which we worked in previous post.
Cross-browser testing libraries does NOT ships with Visual Studio 2013 out of the box, rather, it should be downloaded as an extension from Visual Studio Extensions and Updates as shown below
You can also download from the following link https://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d Read more
Wait is one of the most important operation in any automation testing tool, since we must/may need to wait for a control to fully appear in screen before performing further operations. Thread.Sleep can be used as opposed to Wait, but it’s always a bad practice to use it in code, since this will make our code to wait for time specified explicitly, even if the control appears or enabled on the screen, thread.sleep will make your code to wait for the time.
In tool like Selenium, wait can be done using Implicit and Explicit wait as discussed in the article here
Coded UI on the other hand offers different types of wait methods which is shipped along with Visual Studio as shown below