Skip to main content

Fresh brew with NUnit for Selenium over a cuppa VS2010 Express’o

 

Selenese coffee beans

1) A recorded Selenium script for a simple scenario of googling for the term Tomato. This recording should have been saved as an export in C# format.

2) VS2010 express editors – for C# and Web dev

3) MS Excel

4) Browsers – Chrome, Firefox, IE

5) WebDriver for Google Chrome

Prepare the Coffee Machine

Let’s install NUnit extension, NuGet package manager, Selenium packages and include MS Excel Interop reference into VS2010.

Essentially 2 different editors are required from the VS2010 stable:

a) Microsoft Visual C# 2010 Express – get NUnit

b) Microsoft Visual Web Developer 2010 Express – to get NuGet and Selenium

 

Let’s get started with Microsoft Visual C# 2010 Express –

Invoke Extension Manager:

1. Invoke VS 2010 Express Extension Manager

Browse the Online Gallery and download NUnit Test Application:

2. Visit Online Gallery to download NUnit Test Application

Install NUnit:

3. Download and Install NUnit

Confirm that installation succeeded:

4. On successful installation of NUnit

and this page is displayed in your default browser:

5. On successful installation of NUnit

Choose to create a New Project:

6. Create New Project

Select the NUnit Test Application template for new project, and click on OK:

7. New Project Template - NUnit Test App

A new NUnit Test Project gets created with several useful references that make the NUnit features available to this VS2010 project:

8. Default files in an NUnit project

Now save this project and close this editor.

Launch Microsoft Visual Web Developer 2010 Express (in some cases one may need to invoke this as an Administrator, for installation of NuGet) and open the same project that we saved above.

Launch the Extension Manager and Search for NuGet Package Manager. Install this extension. One may need to close VS2010 and re-launch it on successful installation. Post-installation, confirm that the Library Package Manager menu item is visible in the VS2010 Web Dev Express editor:

9. NuGet Library Package Manager

Open the saved project and then Invoke the Package Manager Console – at the prompt, run this command:

PM> Install-Package Selenium.Support

as per the guidelines here: http://www.nuget.org/packages/Selenium.Support

image

This would trigger a dependency check and all required packages including Selenium.WebDriver should get installed. One may alternately choose to go per the seleniumhq website and individually install the WebDriver first and then the Support packages.

Now choose to add a reference to the project:

image

In the Add Reference dialog, select and add reference to Microsoft Excel Object Library (for Excel 2010):

image

After the reference gets added, expand the References section in Solution Explorer to ensure that these packages are present:

a) Microsoft.Office.Core

b) Microsoft.Office.Interop.Excel

image

Pour the Coffee in a Mug

Let’s now open the Selenium C# script for Firefox. Copy all its contents. Paste into a new Class in VS2010.

Build the project.

Create new classes for IE and Chrome.

Build the project.

Copy Chrome driver file to the VS2010 project’s \bin\debug folder:

image

Sip the Coffee

Run the NUnit project.

Source code is uploaded here (minus these reference packages, in best interest of size):

PackagesList - to be installed for the project

Here’s the run session:

NUnit – Selenium – Chrome_FF_IE

Comments

Popular posts from this blog

Experimenting with Visio and VBScript

This diagram is created:               using this code:                                                                         Copy the code: Option Explicit Dim strVSDPath, filesys Dim vsoApplication, vsoDocument, vsoPages, vsoPage Dim vsoMaster1, vsoMaster2, vsoStencil Dim vsoShape1, vsoShape2, vsoConnector1 Dim itr Const visAutoConnectDirDown = 2     'Connect down. Const visAutoConnectDirLeft = 3     'Connect to the left. Const visAutoConnectDirNone = 0     'Connect without relocating the shapes. Const visAutoConnectDirRight = 4     'Connect to the right. Const visAutoConnectDirUp = 1         'Connect up....

Microsoft Test Manager – FUEL for test automation

(this is a follow-up post to this one:  http://sudiptopaul.blogspot.com/2011/12/using-aspnet-page-state-and-theme-to.html ) Traditionally Test Management and Test Automation tools have been remotely related to each other. Microsoft’s Test Manager changes this - Manual Testers contribute effectively by creating action recordings for each test Common portions of test steps can now be grouped into what is called as Shared Steps – again manual tester can create independent action recordings for these Test Manager enables these action recordings to serve as active inputs to test automation – separate class is created for each test case, and a reusable function for each shared step This is very elegant as it saves the test automation engineer an amount of time required to refactor common portions of longish test path recordings The Manual Tester gets to contribute in the Keyword definition phase – an important thing to do, because they are the subject matter experts! Here’...

Study of an AngularJS application: Feeding Excel based data into an SVG Flowchart with AngularJS and NodeJS

Reference article Implementing a Flowchart with SVG and AngularJS Source code from original article is here .   Customization goals a) Feed the SVG flowchart nodes from excel datasheet b) Understand a bit of the AngularJS and NodeJS client-server communication c) Learn javascript debugging on server side as well as client side using VS Code editor As a beginner to AngularJS-NodeJS, the customization is based on a partial study of the original article .   Most challenging challenge as a dummy There was a space of time when I thought I was publishing the server side JSON data to the same URL as the front-end html page. And then trying to debug it and not knowing why: in one case the data was coming from the server side only, while in the other case it was coming from mocked data on client side. Kept on looking for whether data was getting lost, or did I need routing. There were debug sessions where both server side and client side individually appear...