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.