Skip to content

andreasneuber/csharp-cucumber-selenium-example

Repository files navigation

csharp-cucumber-selenium-example

A sample implementation of BDD UI tests with C# / SpecFlow

Application under test

The feature files, step definitions and page objects were written for https://github.com/andreasneuber/automatic-test-sample-site. Readme in that repo has further details how to set it up.

IDE used

Microsoft Visual Studio Community 2022 (with .NET desktop development workload)

Setup

  • git clone
  • Double-click file csharp-cucumber-selenium-framework.sln
  • Solution opens in Visual Studio
  • Go to "Extensions" > "Manage Extensions" and get "SpecFlow for Visual Studio 2022"
  • Right-click on solution, build solution
  • Go to "View" and open the "Test Explorer" window
  • Click green "Run All Tests In View" button

Updating

Especially ChromeDriver needs frequent updating.

  • Go to "Tools > NuGet Package Manager > Manage NuGet Packages for Solution..."
  • Go to tab "Updates"
  • Update
  • Right-click on solution, build solution
  • Close and reopen solution

Set Browser

Open file app.config and find key "Browser". You can choose between:

  • chrome
  • chrome_headless
  • firefox
  • edge
  • safari After changing the browser, rebuild the solution.

SpecFlow LivingDocs reports locally

Step-by-step guide for LivingDoc Generator

SpecFlow LivingDocs reports on Azure DevOps

To view the "SpecFlow LivingDocs" comfortably an extension is required.

Step SpecFlow+ build step. in file azure-pipelines.yml will generate and upload the report.

Report will appear under menu item "Overview > SpecFlow+ LivingDoc".

Helpful VS keyboard shortcuts

  • Duplicate line: CTRL + E + V
  • Go to definition: F12
  • Quick code formatting: Ctrl + K , Ctrl + D

FAQ

Where can I change the Base Url?

See app.config > appSettings

How can I switch browser to "headless"?

See app.config > appSettings

Error "csharp-cucumber-selenium-framework\bin\Debug\chromedriver.exe". Access to the path 'csharp-cucumber-selenium-framework\bin\Debug\chromedriver.exe' is denied.

  • Run taskkill /f /im chromedriver.exe
  • Clean solution

About

A sample implementation of BDD UI tests with C# and SpecFlow

Topics

Resources

License

Stars

Watchers

Forks