Framework Structure

Directory Structure

    1. Open up Visual Studio Code in the root of your project from Terminal
    2. In the Explorer pane in Visual Studio Code, right-click on the project name (e.g. ProductAutomation) and select ‘New Folder’
      • Name the folder ‘Features’
  1. Repeat the above steps and add the following top-level folders…
    • Pages
    • Steps
    • Utils
  2. Add the following sub-folders to the ‘Utils’ directory…
    • Extensions
    • Hooks
    • Selenium

Initial Files in each Directory

Features Folder

  1. Right-click the ‘Features’ folder and select ‘New File’
  2. In the window that appears, select ‘SpecFlow Feature File’
  3. Add the following ‘Feature’ file…
    • BaseScenarios.feature

Pages Folder

  1. Right-click the ‘Pages’ folder and select ‘Add’ –> ‘New Class’
  2. Add the following class…
    • BasePage.cs

Steps Folder

The steps folder/namespace will contain all our step definition classes, which will contain our step definitions / glue which links our steps in our test scenarios to the c# methods which perform different actions.

When it comes to grouping our step definitions, it is good practice to have a Step Definition class file for each major domain object we are trying to test.

For example, in this blog series, we will mainly be testing that a user can search for “Reddit” on DuckDuckGo and then navigate to Reddit by selecting the appropriate search result.

So in this case, we could have the following Step Definition files…

  1. Right-click the ‘Steps’ folder, select ‘New File’ and add the following classes to the package (the ‘Steps’ folder will contain all our step definitions, which acts as the glue that connects our BDD/Gherkin language scenarios in our Feature files, to our test methods in our C# classes.  Please see for more information)
    • BaseSteps.cs
      • this class contains all the step definitions for your base scenarios and steps that apply across multiple domain objects
    • SearchSteps.cs
      • this class contains all the step definitions for steps that perform actions around searching on DuckDuckGo
    • RedditSteps.cs
      • this class contains all the step definitions for steps that involve Reddit

Utils Folder

Extensions subfolder

  1. Right-click the ‘Extensions’ subfolder, select ‘Add’ –> ‘New Class’ and add the following classes to the namespace (the ‘Extensions’ namespace will contain class files for all extension methods we can use with our existing functionality / test methods)
    • WebDriverExtensions.cs
    • WebElementExtensions.cs

Hooks subfolder

  1. Right-click the ‘Hooks’ subfolder, select ‘Add’ –> ‘New Class’ and add the following classes to the namespace (the ‘Hooks’ namespace will contain classes for all the different hooks we can run before and/or after test runs/suites/scenarios etc.)
    • SpecFlowHooks.cs
    • TestRunHooks.cs

Selenium subfolder

  1. Right-click the ‘Selenium’ subfolder, select ‘Add’ –> ‘New Class’ and add the following classes to the namespace (the ‘Selenium’ namespace will contain our core WebDriver setup and DriverController instance, as well as a Settings class where we can list public static variables to be used in our project)
    • Driver.cs
    • Settings.cs


We will now add a .gitignore file to ignore certain files and packages if/when we push to a remote repository.

  1. Create a file called .gitignore in the root of the framework
    1. Click the Solution file then click the new File button/icon for the very top folder you made to store everything
  2. Add the following into a blank file which is taken from…
    # User-specific files
    # Build results
    # build folder is nowadays used for build scripts and should not be ignored
    # NuGet Packages
    # The packages folder can be ignored because of Package Restore
    # except build/, which is used as an MSBuild target.
    # Uncomment if necessary however generally it will be regenerated when needed
    # MSTest test Results
    # OS generated files #
    # Visual C++ cache files
    # Visual Studio profiler
    # Guidance Automation Toolkit
    # ReSharper is a .NET coding add-in
    # TeamCity is a build add-in
    # DotCover is a Code Coverage Tool
    # NCrunch
    # Installshield output folder
    # DocProject is a documentation generator add-in
    # Click-Once directory
    # Publish Web Output
    # Windows Azure Build Output
    # Windows Store app package directory
    # Others
    # EPiServer Site file (VPP)
    # RIA/Silverlight projects
    # Backup & report files from converting an old project file to a newer
    # Visual Studio version. Backup files are not needed, because we have git ;-)
    # vim
    # Temp files when opening LibreOffice on ubuntu
    # svn
    # CVS - Source Control
    # Remainings from resolving conflicts in Source Control
    # SQL Server files
    #LightSwitch generated files
    # =========================
    # Windows detritus
    # =========================
    # Windows image file caches
    # Folder config file
    # Recycle Bin used on file shares
    # Mac desktop service store files
    # SASS Compiler cache
    # Visual Studio 2014 CTP
    # Visual Studio temp something
    # dotnet stuff
    # VS 2015+
    # Rider
    # Visual Studio Code
    # Output folder used by Webpack or other FE stuff
    # SpecFlow specific
    # End of core ignore list, below put you custom 'per project' settings (patterns or path)
  3. Save the file as ‘.gitignore’ in your project root (where the .sln file exists)

Downloading the Drivers

  1. Create a folder in the root of the whole project called ‘_drivers’


  1. Download the appropriate ChromeDriver for your Chrome browser from
  2. Place the downloaded driver in the ‘_drivers’ folder
Liked it? Take a second to support Thomas on Patreon!

Previous Article

Next Article

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.