Thursday, August 14, 2014

Automating CodedUI with Visual Studio, TFS and Selenium - Part 1

Selenium, CodedUI & Visual Studio – Part 1

CodedUI, a brilliant way to test the behaviour of your application on browser. It is not that dissimilar from unit tests in your application but they work at browser level and make sure that the buttons, content, links, text all are loading at the right place with the right user actions.

Now there are couple of ways by which you can record CodedUI tests for your application but we are majorly going to discuss two approaches only. First is Visual Studio. It gives you an option to record coded UI tests and integrates them with your automated CI and CD builds but is a paid functionality in Visual Studio which comes only with Premium edition. If you do not require any other features of VS premiums then buying them only for CodedUI will be a hit on the pocket.

The other option for CodedUI is the one which we are going to discuss in detail is Selenium and NUnit framework. So we are going to do this in two parts.  First, we will configure the machine with Selenium and in second, will record one test and export that to Visual Studio.

Part 1: Configuring Selenium:

So in order to record CodedUI via Selenium, you need Selenium IDE, Selenium server to run tests and IE Driver if you wish to record/run your tests in IE as well. Let’s start with the Selenium IDE first. Navigate to Selenium website and click downloads as shown below:-






















Download the latest IDE from the link and save it. Now, this IDE is basically an extension of Firefox and hence you have to add this extension in Firefox with below steps:-
  1. Open Firefox, Click Tools -> Add-Ons
  2. Click on Settings next to Search Add-Ons and Install Add-On from File
  3. Select the extension you have just downloaded and it will automatically install it.
Now, go to Tools and you should have Selenium IDE option visible there as shown below:-









Now, next step is only important if you wish to use Selenium RC for running your tests. If you wish to use the new Selenium WebDriver then you don't have to do this step.

Download the Selenium Server from the same Selenium HQ download page. This download is basically a jar file which runs as an standalone http server. In order to run this, you will need the Java JDK which can be downloaded from here. Once, this is installed, copy the jar file in some folder in C drive. Create a bat file in the same folder and copy the below command in it. 

java -jar NAME-OF-JAR-FILE -port 4444 -interactive

Run the bat file and your http server is up and running. Now the final piece is NUnit framework. Download the latest NUnit installer msi from here and install it. Although you might not need this if you are planning to run your tests from Visual Studio but you can surely test your recorded tests straight with this before exporting them to VS.

So this concludes the set-up for Selenium web tests on your machine. In all three components above, you can choose which one to install as per your requirements.

In Part 2, we will discuss how to record CodedUI in FireFox Selenium extension and export them into Visual Studio.

1 comment :

  1. This is the best ever whatsapp and i liked this app for more download Live NetTv and this is not only a single app you can download RedBox Tv there is you can also Chinese Year 2022

    ReplyDelete