Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7628771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:39:30+00:00 2026-05-31T05:39:30+00:00

I want easy way to launch Selenium webdriver instance and run various tests on

  • 0

I want easy way to launch Selenium webdriver instance and run various tests on it. I’m trying to do this in Suite file, but it doesn’t work. Instance is killed instantly. Is there any alternatives on how to do this?

Potentially I want to add more drivers (IE, Chrome) in this suite and if possible launch separately. Any suggestions welcome.

namespace NUnit.Tests
{
   public class AllTests
   {
        private static IWebDriver _Driver;

        [TestFixtureSetUp]
        public void SuiteSetUp() 
        {
           _Driver = new FirefoxDriver();
         }

        [TestFixtureTearDown]
        public void SuiteTearDown()
        {
           try
           {
              _Driver.Quit();
           }
              catch (Exception)
           {
                    // Ignore errors if unable to close the browser
            }
         }

         [Suite]
         public static TestSuite Suite
         {
            get
            {
               LoginTest lt = new LoginTest { Driver=_Driver };
               suite.Add(lt);
               AnotherTest at = new AnotherTest { Driver=_Driver };
               suite.Add(at);
               return suite;
             }
          }


   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:39:32+00:00Added an answer on May 31, 2026 at 5:39 am

    Trying to run this with base class / extended classes failed. As webdriver instance didn’t get initialized properly and couldn’t be killed properly. Instead I created SetupIE(), SetupChrome(), SetupFirefox() methods in Suite and also created teardown method that would work as last test for suite.

    Here is the code:

    namespace TestNamespace
    {
        using System;
        using NUnit.Framework;
        using NUnit.Core;
        using SeleniumTests;
        using OpenQA.Selenium;
        using OpenQA.Selenium.IE;
        using OpenQA.Selenium.Firefox;
        using OpenQA.Selenium.Chrome;
        using OpenQA.Selenium.Support.UI;
    
        class AllTests
        {
            public static IWebDriver WebDriver { get; private set; }
    
            [Suite]
            public static TestSuite Suite
            {
                get
                {
                    TestSuite suite = new TestSuite("All Tests");
    
                    //Setup a Web driver (see methods below for different browsers) - SetupIE(), SetupChrome(), SetupFirefox()
                    SetupIE();
    
                    // Add tests to suite
                    suite.Add(new FlashLoadedTest { Driver = WebDriver });
    
                    // Tear down a Web driver
                    suite.Add(new TearDownTest { DriverToTearDown = WebDriver });
    
                    // return suite to NUnit
                    return suite;
                }
            }
    
            // Method that's initialises FireFox Driver
            private static void SetupFireFox()
            {
                WebDriver = new FirefoxDriver();
            }
    
            // Method that's initialises IE Driver
            private static void SetupIE()
            {
                WebDriver = new InternetExplorerDriver(); 
            }
    
    
            // Can't get this working, but this is how its supposed to work
            private static void SetupChrome()
            {
                WebDriver = new ChromeDriver(@"C:\Users\<user>\AppData\Local\Google\Chrome\Application");
            }
    
    
            // Class with a test that tears down browser instance
            [TestFixture]
            class TearDownTest
            {
                public IWebDriver DriverToTearDown;
    
                [Test]
                public void TearDownBrowser()
                {
                    if (DriverToTearDown == null)
                        Assert.Fail("No Browser to Tear Down");
    
                    try
                    {
                        DriverToTearDown.Close();
                        DriverToTearDown.Dispose();
                    }
                    catch
                    {
                        Assert.Fail("Browser failed to tear down");
                    }
                }
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In there an easy way to do this in PHP. I want to make
Is there an easy way of cloning entire installed debian/ubuntu system? I want to
All I want to know is if there's an easy way to add lines
Simple question, hopefully an easy way and just want to verify I'm doing it
This should be an absurdly easy task: I want to take each line of
Let's make this very easy. What I want: @array = qw/one two one/; my
I want a quick an easy way to check my ip address after reading
I want to move column OtherSupport below Amount2 ... is there an easy way
I want to remove everything inside my git project. Is there any easy way
I want an easy way to create css files that contain different colors. Sass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.