Global Directory
Global Directory
EXPLORE OUR SITES
London Stock Exchange Group
LSEG Data & Analytics
MyAccount
LSEG Perspectives
London Stock Exchange
FTSE Russell
LCH
Contact Us
Home
TR Internal
Additional ways of closing ChromeDriver using Selenium?
Brad Starin
Executing automated test cases using Selenium invokes the ChromeDriver during execution. The test cases execute and compelte successfully. However, using DriverClose() and DriverQuit() does not close down the Chrome browsers or ChromeDriver.exe. Also finding the same when using the IEDriverServer.exe.
Does anyone have any experience with alternatives to closing the ChromeDriver.exe?
Find more posts tagged with
driver
refinitiv-internal
Accepted answers
All comments
Benjamin Fairchild
In Java at least we do it this way:
Setup:
private void initializeChromeDriver() throws IOException
{
// Start Chrome in maximized window
final ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized", "--allow-running-insecure-content");
final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
org.openqa.selenium.remote.service.DriverService driverService = new ChromeDriverService.Builder().usingDriverExecutable(new File("./resources/driver/chromeDriver.exe")).usingAnyFreePort().build();
driverService.start();
webDriver = new ChromeDriver((ChromeDriverService)driverService, options);
}
Teardown:
if(webDriver != null)
{
webDriver.quit();
}
if(driverService != null)
{
driverService.stop();
}
Rolandas Burbulis
We call Quit() method on the driver and it works fine. Make sure to put this in the method that has [TestCleanup] attribute in a class your tests extend from. Also make sure to put in a finally clause in case any exception occurs in the cleanup process (such as failing to sign off, failing to checkin password back into the pool, etc.).
Benjamin Fairchild
Oh, right IE too. Here is the set up part for IE:
driverService = new InternetExplorerDriverService.Builder().usingDriverExecutable(new File("./resources/driver/IEDriverServer.exe")).usingAnyFreePort().build();
driverService.start();
webDriver = new RemoteWebDriver(driverService.getUrl(), DesiredCapabilities.internetExplorer());
Quick Links
All Forums
Recent Questions
Terms of use
Privacy & Cookie Statement
Cookies settings
Do not sell my info
Whistleblowing
UK Bribery Act
Modern Slavery Act