Hello Folks,

Let’s learn something interesting in selenium webdriver.

We know whenever we launch a browser, first browser serve is started which helps in communication between browser and selenium commands. The same process is repeated for every test if you launch and quit browser every time.

Let’s understand above point with an example below:

Run below program and observe output:

Console Output:

You can see chrome driver server started twice as you have two @Test methods and you are launching and quitting browser for every @Test methods.

Suppose if you have a bigger suite, it will take a good amount of time in starting and killing server. It will also increase your test execution time.

Selenium provides you option to control starting and killing of browser server. You can use TestNG annotated methods to start server once and kill it after suite is completed. It will save a lot of execution time.

Selenium provides a browser specific service class  for controlling server. For example: ChromeDriverService for Chrome browser, GeckoDriverService for Firefox browser. Refer below program to understand that.

Console output:

You can see only once browser server started. You can check the amount of time saved by putting start and end time in scripts.

Hope you enjoyed this post.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappySelenium

2 thoughts on “Controlling Browser Driver Services In Selenium WebDriver

  1. I don’t know whether i like Selenium or not, I am a big fan of your Selenium articles. It makes me think Selenium is easy to learn. Keep up your hard work Amod. God Bless.

Leave a Reply