No connection could be made because the target machine actively refused it(selenium)

后端 未结 7 700
别那么骄傲
别那么骄傲 2021-02-07 00:59

I have extracted the following code from selenium IDE.(c# remote control)

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Thr         


        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 01:21

    This is the way i do it, the structure of my class.

     [TestFixture, Parallelizable(ParallelScope.None)]
     public class UserTest : BaseTestClass
     {
                [SetUp]
                public void SetUp()
                {
                    ChromeOptions options = new ChromeOptions();
                    //options.AddArgument("--headless");
                    options.AddArgument("--start-maximized");
                    var driver = new ChromeDriver(options);
                    WebDriver = WebDriverExtended.InitWebDriver(driver, driver.Url);
                    WebDriver.Start();
                }
    
               [TearDown]
                public void Cleanup()
                {
                 //Dispose after every single test, fixed the problem.
                    WebDriver.Close();
                    WebDriver.Quit();
                    WebDriver.Dispose();
                }
    
          [Test]
          public void LoginTest()
          {
           //My test ...
          }
    }
    

    I am currently using Selenium.Support v3.6.0 and Selenium.WebDriver v3.6.0. Disposing the webdriver fixed my problem

    No connection could be made because the target machine actively refused it 127.0.0.1:4444

提交回复
热议问题