I have been attempting to close the browser in my Selenium Jmeter last sampler thread, but I keep encountering the following error:
INFO c.g.j.p.w.s.WebDriverSampler: WebDriver has been quit.
2024-02-01 22:53:24,989 ERROR c.g.j.p.w.s.WebDriverSampler: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '4.10.0', revision: 'c14d967899'
I have tried various methods to close it, such as:
WDS.browser.quit()
and
WDS.browser.Close()
Below is a snippet of my code:
var handles = WDS.browser.getWindowHandles().toArray();
WDS.browser.switchTo().window(handles[handles.length - 1]);
java.lang.Thread.sleep(3000);
WDS.browser.close();
WDS.log.info("(ACO Dashboard Visit 360 Map) Page loaded correctly.");
} else {
WDS.log.info("The Trimmed text does not contain 'Visit 360'. Skipping click.");
}
} catch (err) {
WDS.log.error("Error: " + err);
} finally {
WDS.browser.quit();
WDS.log.info("WebDriver has been quit.");
}