* Pins the Grid node to the Bazel-provided driver and browser; on CI, Selenium Manager would find * no installed browser. * @param {!Array } browserNames the browsers sharing the server. * @return {!Array } empty to keep driver detection.
(browserNames)
| 630 | * @return {!Array<string>} empty to keep driver detection. |
| 631 | */ |
| 632 | function pinnedGridArgs(browserNames) { |
| 633 | // The command line merges repeated --driver-configuration flags into one, so only a single |
| 634 | // browser can be pinned; with several, detection must stay on to give each one a slot. |
| 635 | if (browserNames.length !== 1) { |
| 636 | return [] |
| 637 | } |
| 638 | const [browserName] = browserNames |
| 639 | const [driverVar, browserVar, vendorKey] = PINNED_BROWSERS[browserName] ?? [] |
| 640 | if (!process.env[driverVar] || !process.env[browserVar]) { |
| 641 | return [] |
| 642 | } |
| 643 | const stereotype = JSON.stringify({ browserName, [vendorKey]: { binary: locate(process.env[browserVar]) } }) |
| 644 | return [ |
| 645 | '--detect-drivers', |
| 646 | 'false', |
| 647 | '--driver-configuration', |
| 648 | `display-name=${browserName}`, |
| 649 | 'max-sessions=1', |
| 650 | `webdriver-executable=${locate(process.env[driverVar])}`, |
| 651 | `stereotype=${stereotype}`, |
| 652 | ] |
| 653 | } |
| 654 | |
| 655 | function locate(fileLike) { |
| 656 | if (fs.existsSync(fileLike)) { |