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:
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.
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.
Author: Amod Mahajan
My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning