diff --git a/javascript/node/selenium-webdriver/testing/index.js b/javascript/node/selenium-webdriver/testing/index.js index 116009e26ea22..c96f18d453592 100644 --- a/javascript/node/selenium-webdriver/testing/index.js +++ b/javascript/node/selenium-webdriver/testing/index.js @@ -35,7 +35,6 @@ const fs = require('node:fs') const path = require('node:path') const { isatty } = require('node:tty') -const { runfiles } = require('@bazel/runfiles') const chrome = require('../chrome') const edge = require('../edge') const firefox = require('../firefox') @@ -46,6 +45,14 @@ const { Browser } = require('../lib/capabilities') const { Builder } = require('../index') const { getBinaryPaths } = require('../common/driverFinder') +let runfiles +try { + // Attempt to require @bazel/runfiles + runfiles = require('@bazel/runfiles').runfiles +} catch { + // Fall through +} + /** * Describes a browser targeted by a {@linkplain suite test suite}. * @record @@ -544,6 +551,10 @@ function locate(fileLike) { return fileLike } + if (!runfiles) { + throw new Error('Unable to find ' + fileLike) + } + try { return runfiles.resolve(fileLike) } catch {