I am running UI automation locally using selenium webdriver, chromedriver, and jest, on MacOS. After several runs I run out of local storage. You can watch storage decrease by about 50 gb every run. When I restart my computer, the storage cleans up and I have space again. I am wondering if I am not cleaning up my tests correctly.

Here are my dependencies:

  "devDependencies": {
    "@babel/core": "^7.14.6",
    "@babel/runtime": "^7.14.6",
    "@types/jest": "^26.0.23",
    "@types/node": "^14.14.31",
    "@types/selenium-webdriver": "^4.0.14",
    "@typescript-eslint/eslint-plugin": "^4.28.1",
    "@typescript-eslint/parser": "^4.28.1",
    "babel-jest": "^27.0.6",
    "babel-plugin-add-react-displayname": "^0.0.5",
    "chromedriver": "^91.0.1",
    "eslint": "^7.30.0",
    "eslint-plugin-react": "^7.24.0",
    "fsevents": "^2.3.2",
    "geckodriver": "^2.0.1",
    "jasmine": "^3.8.0",
    "jest": "^27.0.6",
    "metro-react-native-babel-preset": "^0.66.0",
    "prettier": "^2.3.2",
    "react-native-dotenv": "^3.0.0",
    "run-node": "^2.0.0",
    "selenium-webdriver": "^4.0.0-beta.4",
    "ts-jest": "^27.0.3",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^4.4.0-dev.20210609",
    "weak-napi": "^2.0.2",
    "webdriver": "^7.7.4",
    "webdriver-manager": "^12.1.8",
    "webdriverio": "^7.7.4"

Here is my cleanup method:

/** Cleans up all drivers created by this process */
export async function cleanupDrivers(): Promise<void> {
  await Promise.all(driversToCleanUp.map((driver) => driver.quit()));

My driver creation method:

const driversToCleanUp: WebDriver[] = [];

/** Configures a new WebDriver for e2e testing */
export async function buildDriver(): Promise<WebDriver> {
  const driver = await new Builder()
    .setChromeOptions(setChromeOptions(new chrome.Options()))
    .setFirefoxOptions(setFirefoxOptions(new firefox.Options()))

  return driver;

/** Configures a new WebDriver for download testing */
export async function buildDownloadDriver(): Promise<WebDriver> {
  const driver = await new Builder()
    .forBrowser("chrome") // do not change this
    .setChromeOptions(setChromeDownloadOptions(new chrome.Options()))

  return driver;

/** Sets chrome options for WebDriver */
function setChromeOptions<T extends chrome.Options>(options: T): T {
  options.windowSize({ width: 1920, height: 1080 });

  return options;

Not sure if this is enough information, but I am happy to provide more. Thanks for any help!

I have temporarily solved this by creating and running a bash script via yarn command:

# navigates to folder to clean chrome driver files
cd && cd  ../../private/var/folders/fg/{yourIDhere}/T

# deletes chromedriver leftover files
rm -rf .com.google.Chrome.*
  • just restart browser before each scenario
    – PDHide
    Jul 8 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.