Getting Started

Introduction

In this series, we will set up an automation framework from scratch to test against the frontend of a web application.

The completed repository can be found at https://gitlab.com/testifyqa/CSharp-Web-Selenium

We will use the following in our test framework:

  • Selenium WebDriver
    • Selenium is a portable software-testing framework for web applications. Selenium provides a playback (formerly also recording) tool for authoring tests without the need to learn a test scripting language (Selenium IDE). It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including C#, Groovy, Java, Perl, PHP, Python, Ruby and Scala. The tests can then run against most modern web browsers. Selenium deploys on Windows, Linux, and macOS platforms. It is open-source software, released under the Apache 2.0 license: web developers can download and use it without charge.
      • We will set up WebDrivers for automation in Google Chrome and Mozilla Firefox
  • SpecFlow
    • Use SpecFlow to define, manage and automatically execute human-readable acceptance tests in .NET projects. Writing easily understandable tests (in Gherkin language) is a cornerstone of the BDD paradigm and also helps build up a living documentation of your system.
  • NUnit
    • NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 3, has been completely rewritten with many new features and support for a wide range of .NET platforms.
  • SpecFlow.NUnit
    • A combined package to get SpecFlow setup and working with NUnit

Setup / Installation

Setting up Visual Studio

  1. Download Visual Studio from https://www.visualstudio.com/downloads/
  2. Complete installation of Visual Studio on your Windows machine

Setting up ReSharper (optional)

ReSharper is a popular developer productivity extension for Microsoft Visual Studio. It automates most of what can be automated in your coding routines. It finds compiler errors, runtime errors, redundancies, and code smells right as you type, suggesting intelligent corrections for them.

  1. Download ReSharper from https://www.jetbrains.com/resharper/download/
    1. Sign up to a trial account if necessary
  2. Install ReSharper and customise your settings based on being used to Java and Automation (C# and Java are similar when using Selenium WebDriver API)
  3. Close down and restart Visual Studio

Creating an Automation Test Project in Visual Studio

  1. Launch Visual Studio
  2. Click File → New → Project
  3. Select Visual C# → Console Application (.NET Framework) – we can use the console app to leave messages about our tests and help us debug
  4. Name the Console App project something suitable (e.g. ProductAutomation) and also name the Solution itself something appropriate

Installing Visual Studio Extensions

  1. Click Tools –> Extensions and Updates
  2. In the Extensions and Updates window, click the ‘Online’ section
  3. Search for ‘SpecFlow’ and download ‘SpecFlow for Visual Studio 2017’
  4. Next, search for ‘NUnit’ and download ‘NUnit 3 Test Adapter’
  5. Next search for ‘Productivity Power Tools’ and download ‘Productivity Power Tools 2017’
  6. Click Close and then close down Visual Studio to get the installer window to appear
  7. Click on ‘Modify’ to agree to the terms and then click ‘End Tasks’ (if necessary) to install the extensions
  8. Open Visual Studio and reload the Automation project

Installing NuGet Packages

  1. In the Solution Explorer, right-click on ‘References’ and click on ‘Manage NuGet Packages…’
  2. In the window that opens, select the ‘Browse’ tab…

NUnit Packages

NUnit Test Adapter

  1. Search for ‘NUnit’
  2. Select ‘NUnit3TestAdapter’ and install the latest version of the package

Selenium Packages

Chrome WebDriver

  1. Search for ‘Chrome WebDriver’
  2. Select ‘Selenium.Chrome.WebDriver’ and install the latest version of the package

Firefox WebDriver

  1. Search for ‘Firefox WebDriver’
  2. Select ‘Selenium.Firefox.WebDriver’ and install the latest version of the package

Selenium WebDriver

  1. Search for ‘Selenium’
  2. Select ‘Selenium.WebDriver’ and install the latest version of the package

Selenium Support

  1. Search for ‘Selenium’
  2. Select ‘Selenium.Support’ and install the latest version of the package

Selenium Extras

  1. Search for ‘DotNetSeleniumExtras’
DotNetSeleniumExtras.PageObjects
  1. Select ‘DotNetSeleniumExtras.PageObjects’ and install the latest version of the package’
DotNetSeleniumExtras.WaitHelpers
  1. Select ‘DotNetSeleniumExtras.WaitHelpers’ and install the latest version of the package’

SpecFlow Packages

SpecFlow

  1. Search for ‘SpecFlow’
  2. Select ‘SpecFlow’ and install the latest version of the package

SpecFlow Assist Dynamic

  1. Search for ‘SpecFlow Assist Dynamic’
  2. Select ‘SpecFlow.Assist.Dynamic’ and install the latest version of the package

SpecFlow.NUnit

  1. Search for ‘SpecFlow.NUnit’
  2. Select ‘SpecFlow.NUnit’ and install the latest version of the package

 

 

 

 

Digiprove sealCopyright secured by Digiprove © 2018
Liked it? Take a second to support Thomas on Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.