Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How ChromeDriverService is useful in selenium automation

We have ChromeDriverService class available in org.openqa.selenium.chrome ...

I understand this will help in starting the chrome driver on any port of the machine with the below code...

ChromeDriverService src = new ChromeDriverService.Builder().usingDriverExecutable(new File("Location of chromedriver.executable")).usingAnyFreePort().build();
src.start();

But not sure of how this is helpful for us in the automation, in which scenario this can be used ...

If we want to start the chrome browser with RemoteWebDriver having the DesiredCapability with Chrome, then we need to start running the selenium server standalone... the above ChromeDriverService is not useful there..

Please throw some light on ChromeDriverService

like image 779
Traveller87 Avatar asked Dec 03 '13 11:12

Traveller87


1 Answers

The purpose of ChromeDriverService is to manage a persistent instance of the ChromeDriver server.

Standard practice is to use the ChromeDriver class or the Selenium standalone server to obtain Chrome driver instances, but this practice sacrifices performance for convenience. In this scenario, each driver instance is associated with its own instance of the ChromeDriver server, which gets launched when the driver is requested and terminated when the driver exits. This per-instance server management adds overhead to test execution, both in terms of run-time and resource utilization.

Using ChromeDriverService, this overhead can be reduced to a minimum by enabling your test framework to launch a server instance at the start of the test suite and shut it down when the suite finishes. An example of this approach can be found on the ChromeDriver Getting started page under the heading Controlling ChromeDriver's lifetime.

like image 189
Scott Babcock Avatar answered Oct 23 '22 03:10

Scott Babcock