I started using headless chrome for jenkins integration and changed the code in my base file. but now when i run a test I see multiple chromedrivers are started and the driver doesn't close when the last test is finished.
I didn't have this problem before switching to headless mode.
Here is my TestBase class TestBase.class
And here is the problem. After all these new chromedrivers the test runs successfully, but a lot of chromedriver accumulates in the background. problem
I tried to use driver.close and driver.quit functions in the test's @After method but it didn't work like old times too. After using headless mode, I can't close them because as you can see there are multiple chromedrivers in the background.
CodePudding user response:
If you want to obtain control over the service itself you need to use DriverService
object. The example:
ChromeOptions options = new ChromeOptions() // Your options here
ChromeDriverService service = ChromeDriverService
.createServiceWithConfig(options);
service.start();
WebDriver driver = new ChromeDriver(service);
// Do your test here
driver.quit(); // close session
service.stop(); // stop service