- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to run Selenium tests in multiple browsers one after another from C# NUnit?
We can run Selenium tests in multiple browsers one after another from C# NUnit. This is done with the help of the Test Fixture concept. This is an attribute that identifies a class, step up and tear down methods.
There are some rules to be followed for a class to have a fixture −
It should not be of type abstract.
There should be a default constructor for a non−parameterized fixture.
The parameterized fixture should have a constructor.
It can be publicly exported.
Example
using NUnit.Framework; using OpenQA.Selenium using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Firefox; using System; namespace NUnitTestProject1{ //Test Fixture declaration [TestFixture(typeof(FirefoxDriver))] [TestFixture(typeof(ChromeDriver))] public class MultipleBrowser<TWebDriver> where TWebDriver : IWebDriver, new(){ private IWebDriver driver; [SetUp] public void CreateDriver(){ this.driver = new TWebDriver(); } [Test] public void Test1(){ //launching URL. driver.Navigate() .GoToUrl("https://www.tutorialspoint.com/index.htm"); } [TearDown] public void close_Browser(){ driver.Quit(); } } }
- Related Articles
- How to run Selenium tests on Chrome Browser using?
- How to run Selenium tests on Internet Explorer browser?
- How to pass multiple data from one activity to another in Android?
- How to run a selected test from a set of tests in pytest?
- How to run a specific group of tests in TestNG from command line?
- How to run multiple test cases using TestNG Test Suite in Selenium?
- C Sharp with Selenium - How to Switch one tab to another tab in Csharp Selenium?
- How can I make one Python file run another?
- How to maximize and minimize browsers in Selenium with python?
- How to click on across browsers using Selenium Webdriver?
- How to run tests using a test runner file for Cucumber?
- How to run multiple test classes in TestNG?
- How to input multiple values from user in one line in C#?
- How to group selected tests from a set of tests in pytest?
- How to run Selenium WebDriver test cases in Chrome?

Advertisements