Skip to content

Instantly share code, notes, and snippets.

@borodicht
Created April 28, 2026 17:01
Show Gist options
  • Select an option

  • Save borodicht/63b2727ecab83bcaa8ffbc59539680c1 to your computer and use it in GitHub Desktop.

Select an option

Save borodicht/63b2727ecab83bcaa8ffbc59539680c1 to your computer and use it in GitHub Desktop.
package tests;
import org.openqa.selenium.WebDriver;
public class DriverManager {
private static final ThreadLocal<WebDriver> driverThreadLocal = new ThreadLocal<>();
public static WebDriver getDriver() {
return driverThreadLocal.get();
}
public static void setDriver(WebDriver driver) {
driverThreadLocal.set(driver);
}
public static void quitDriver() {
WebDriver driver = driverThreadLocal.get();
if (driver != null) {
driver.quit();
driverThreadLocal.remove();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment