
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Automated Software Testing with SpecFlow in Selenium
We can have automated software testing with SpecFlow by configuring Selenium in C#. We will use the Visual Studio editor, to develop the Selenium tests using the NUnit framework. Click on Create a new project from the Visual Studio welcome page.
Enter NUnit in the search edit box within the Create a new project window. Then choose the option NUnit Test Project(.NET Core) from the result dropdown. Click on Next to proceed.
Populate the Project name, Location and click on Create.
Once the project is successfully configured, the Setup and Test methods are provided automatically along with the import statement - using NUnit.Framework.
Then click on the Tools menu and choose the option NuGet Package Manager. Next, click on Package Manager Console.
Execute the following commands in the Package Manager Console, for Selenium installation −
Install-Package Selenium.WebDriver Install-Package Selenium.Firefox.WebDriver Install-Package Selenium.Chrome.WebDriver
Execute the following commands for NUnit installation in the Package Console −
Install-Package NUnit Install-Package NUnit3TestAdapter
To verify that all the required packages have been installed successfully, run the command −
Get-Package
Example
Implementation with Selenium WebDriver in C#
using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System; namespace NUnitTestProject1{ public class Tests{ String url = "https://www.tutorialspoint.com/index.htm"; IWebDriver driver; [SetUp] public void Setup(){ //creating object of FirefoxDriver driver = new FirefoxDriver("<path of geckodriver.exe>"); } [Test] public void Test1(){ //URL launch driver.Navigate().GoToUrl(url); Console.WriteLine("Url launched"); } [TearDown] public void close_Browser(){ driver.Close(); } } }