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 7780309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:51:15+00:00 2026-06-01T18:51:15+00:00

I’m testing a website with Specflow and WebDriver . I’m using events of specflow

  • 0

I’m testing a website with Specflow and WebDriver.
I’m using events of specflow to start and quit the Driver. I start the Driver in [BeforeFeature] and quit it in [AfterFeature].

I use a static Common Class to hold the Driver and have the methods to operate it.

The problem happens after all tests are run on a feature and the next feature starts to run. I get the following errors.:

If in the [AfterFeature] I do a Driver.Close() I get the error:

    -> error: Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:7055
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\HttpCommandExecutor.cs:line 91
   at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Execute(Command commandToExecute) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Firefox\Internal\ExtensionConnection.cs:line 128
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 795

If I do a Driver.Quit() I get the error:

-> error: Cannot deserialize JSON object into type 'System.String'. Line 1, position 35.

If I don’t close or quit the driver, Every Features run with no problem, but I get lots of opened Firefox Windows.

My code is:

[Binding]
public class Events
{
    [BeforeFeature]
    public static void BeforeFeature()
    {
        Common.CreateDriver();
    }

    [AfterFeature]
    public static void AfterFeature()
    {
        Common.QuitDriver();
    }
}

And…

public static class Common
{
    public static IWebDriver Driver { get; set; }        

    public static void CreateDriver(){            
        Driver = new FirefoxDriver();
        Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 5));        
    }

    public static void CloseDriver()
    {
        Driver.Close();
    }

    public static void QuitDriver()
    {
        Driver.Quit();
    }
}
  • 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-06-01T18:51:17+00:00Added an answer on June 1, 2026 at 6:51 pm

    Just found out what the problem was.
    I will put it here for future reference.

    The problem was in the way I was reading the Driver on my BaseWebObject, the father of all PageObjects.

    I had this:

        public class BaseWebObject
    {        
        protected static IWebDriver Driver = Common.Driver;
    
    }   
    

    This Fails because the Driver will only be read once in the static constructor.

    To make it work I must read the Driver at the instantiation time, so in the instance constructor like so:

        public class BaseWebObject
    {        
        protected static IWebDriver Driver;
    
        public BaseWebObject()
        {
            Driver = Common.Driver;
        }    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.