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:
Browse the Online Gallery and download NUnit Test Application:
Install NUnit:
Confirm that installation succeeded:
and this page is displayed in your default browser:
Choose to create a New Project:
Select the NUnit Test Application template for new project, and click on OK:
A new NUnit Test Project gets created with several useful references that make the NUnit features available to this VS2010 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:
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
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:
In the Add Reference dialog, select and add reference to Microsoft Excel Object Library (for Excel 2010):
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
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:
Sip the Coffee
Run the NUnit project.
Source code is uploaded here (minus these reference packages, in best interest of size):
Here’s the run session:
Comments
Post a Comment