CAPABILITY GENERATOR

LambdaTest DocumentationAutomation Testing ● SpecFlow with Selenium – Running SpecFlow Automation Scripts on LambdaTest Selenium Grid

SpecFlow with Selenium – Running SpecFlow Automation Scripts on LambdaTest Selenium Grid


LambdaTest offers support with Selenium WebDriver to help you instantly execute your automation test scripts. LambdaTest is a cloud-based, cross browser testing tool offering a Selenium grid consisting of 2000+ browsers and browser versions running on real operating systems to pace up automation testing of your web-app or website. In this topic, you will learn how to automate your website testing using Selenium with SpecFlow on LambdaTest.

In this topic you will be learning:

  1. How to run a sample Selenium script with SpecFlow on LambdaTest Automation.
  2. How to specify which browsers to run the test on.
  3. How to run your test cases in parallel to reduce build times.
  4. How to test your locally hosted pages.
  5. How to leverage LambdaTest’s Advanced capabilities.

Prerequisites For Running SpecFlow and Selenium


  • Make sure you work with latest version of C#.
  • Download and Install Selenium WebDriver from the official website.
  • .Net framework to deliver guidelines while developing a range of application using C#.
  • You can download and install SpecFlow packages from the NuGet Gallery.
  • Have a project set up in Microsoft Visual Studio.
  • Visit the Library Package Manager → Manage Nuget Package for Solution → Hit Online & then Next.
  • Search for SpecFlow in the Search Packages & hit Install. Refer to their official documentation for more detail.
  • Download Selenium WebDriver Language Binding for C# and extract them to appropriate folder.
  • A .NET Core SDK of 2.1 or greater version.
  • You would also need Lambda Tunnel binary file for testing your locally hosted or privately hosted projects.

Getting Started With SpecFlow and LambdaTest


The first step in using LambdaTest platform is to understand LambdaTest’s Selenium Grid capabilities. Our Selenium Grid uses remote WebDriver instead of normal Selenium client browser drivers so if you are migrating from locally run Selenium, you would have to invoke LambdaTest Selenium remote WebDriver. Next, you need to specify in your code, which browser, browser versions, operating systems, and resolution you wish to run your test on, along with defining LambdaTest specific capabilities. You can check out LambdaTest Capabilities Generator tool to understand more about how you can define running browser environments and leverage advanced LambdaTest capabilities.

First Test With SpecFlow


Let us begin with a simple Selenium Remote Webdriver test first. The C# script with SpecFlow below tests a simple to-do application with basic functionalities like mark items as done, add items in a list, calculate total pending items etc. You can also find this at GitHub.

Here is a code based for the same on SpecFlow a C# specific test automation framework.

You can use the Platform Configuration to specify the desired capabilities for any browser/platform combination you want for your test.

The Selenium Webdriver test would open a URL, mark the first two items in the list as done, add an item in the list, and return the total number of pending items. Your results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on LambdaTest dashboard. LambdaTest Dashboard will help you view all your text logs, screenshots and video recording for your entire Selenium tests.

Execute The Test


You would need to execute the below command in your terminal/cmd.