Save 25% Selenium test time with WebDriverService
There are many articles on the net explaining how to automate browser testing using WebDriver like ChromeDriver driver = new ChromeDriver();
There exists another way — ChromeDriverService which can be used as well. But why would anyone need it? The answer is simple — it saves time. As per google doc,
The ChromeDriver class starts the ChromeDriver server process at creation and terminates it when quit is called. This can waste a significant amount of time for large test suites where a ChromeDriver instance is created per test.
Implementing DriverService
Implementation is pretty straightforward as shown below,

The C# API documentation for ChromeDriverService can be found here.
Performance Comparison
Lets compare time taken to invoke & dispose WebDriver and WebDriverService. The code contains 10 loops, navigating a webpage on local machine with 300 ms sleep.
1. Code & Output
- WebDriver


- WebDriverService


2. Result comparison
After running both codes on my machine, below are the results which shows WebDriverService is around 25% faster than WebDriver. The code was ran 5 times for detailed result.

Practical Usage
Using Selenium WebDriverService is helpful when :-
- Large number of testcases which contains browser invocation.
- Large number of testcases with multiple browser.