Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium.WebDriver.ChromeDriver slow to launch - why?

I've created the simplest-possible NUnit test to initialise a ChromeDriver, and it's taking nearly 6 seconds to run. Most of the time (roughly 4s) is spent with a blank, inactive Chrome window.

Blank Chrome window looks like this

The ChromeDriver.exe window appears almost instantly.

ChromeDriver.exe window

My unit test looks like this:

[Test]
public void Simplest_Possible_Test()
{
    var options = new ChromeOptions { Proxy = null };
    using (new ChromeDriver(options))
    {
        // Do nothing
    }
}

and I'm using these nuget packages:

  <package id="NUnit" version="3.12.0" targetFramework="net47" />
  <package id="Selenium.Support" version="3.141.0" targetFramework="net47" />
  <package id="Selenium.WebDriver" version="3.141.0" targetFramework="net47" />
  <package id="Selenium.WebDriver.ChromeDriver" version="78.0.3904.7000" targetFramework="net47" />

My question is:

Is this slowness expected? Can I do anything to speed it up?

like image 904
Paul Suart Avatar asked Nov 26 '25 02:11

Paul Suart


1 Answers

I am using following singleton IWebDriver instance and it only takes couple of seconds to launch.

public class UiTest : IDisposable
{
    private IWebDriver driver = null;

    protected IWebDriver Driver
    {
        get
        {
            if (driver == null)
            {
                driver = new ChromeDriver(new ChromeOptions{Proxy = null});
                driver.Manage().Window.Maximize();
            }
            return _driver;
        }
    }

    public void Dispose()
    {
        driver?.Dispose();
    }
}

In windows Automatic proxy setup, you can turn off "Automatic detect settings" and see if there is any difference. However, passing null proxy for ChromeOptions has the similar effect, I guess.

enter image description here

like image 113
CharithJ Avatar answered Nov 27 '25 17:11

CharithJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!