#8373·nw.js

使用封装的 chromedriver 进行的 Selenium 测试在 Linux ARM64 上崩溃

作者: ayushmanchhabra创建于 2026年8月16日更新于 2026年8月26日

import { assert } from "node:console"; import path from "node:path"; import process from "node:process"; import { after, before, describe, it } from "node:test";

import get from "@nwutils/getter"; import chrome from "selenium-webdriver/chrome.js";

const nwOptions = { version: "0.114.1", flavor: "sdk", platform: "linux", arch: "arm64", downloadUrl: "https://dl.nwjs.io", manifestUrl: "https://nwjs.io/versions.json", cacheDir: "./cache", srcDir: "./src", outDir: "./out", glob: false, argv: [], managedManifest: "./src/package.json", cache: true, ffmpeg: false, nativeAddon: false, shaSum: true, };

describe("NW.js Selenium ServiceBuilder test suite", async () => { let driver = undefined;

/* Setup Selenium driver. / before(async function () { / Get NW.js */ await get(nwOptions);

/* Initialise Chrome options */
const chromeOptions = new chrome.Options();

const seleniumArguments = ["nwapp=" + path.resolve("./src")];

/* Run in headless mode when in CI environment. */
if (process.env.CI) {
  seleniumArguments.push("headless=new");
}

chromeOptions.addArguments(seleniumArguments);

let nwDirPath = path.resolve(
  nwOptions.cacheDir,
  `nwjs${nwOptions.flavor === "sdk" ? "-sdk" : ""}`
);

chromeOptions.binary = path.resolve(nwDirPath, "nw.js");

driver = await chrome.build(chromeOptions);

});

it("should be able to start a browser", async () => { assert.equal(await driver.getTitle(), "Title"); });

it("should be able to close the browser", async () => { await driver.quit(); }); });