Skip to content

Commit

Permalink
chore(test): add selenium test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Mar 25, 2024
1 parent 63a0a28 commit 742aa6f
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 1 deletion.
144 changes: 144 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"application"
],
"devDependencies": {
"selenium-webdriver": "^4.18.1",
"vitest": "^1.4.0"
}
}
2 changes: 1 addition & 1 deletion test/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title>NW.js Demo</title>
</head>

<body>
<body id="test">
Hello, World! Is anyone out there?
</body>
</html>
32 changes: 32 additions & 0 deletions test/selenium.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import assert from "node:assert";
import path from "node:path";
import process from "node:process";

import { By } from "selenium-webdriver";
import chrome from "selenium-webdriver/chrome.js";
import { describe, it } from "vitest";

import util from "../src/util.js";

const { Driver, ServiceBuilder, Options } = chrome;

describe("run", async () => {
let driver = undefined;

it("should run after build", async () => {
const options = new Options();
const args = [
`--nwapp=${path.resolve("test", "app")}`,
"--headless=new",
];
options.addArguments(args);

const chromedriverPath = util.findpath("chromedriver");

const service = new ServiceBuilder(chromedriverPath).build();

driver = Driver.createSession(options, service);
const text = await driver.findElement(By.id("test")).getText();
assert.strictEqual(text, "Hello, World! Is anyone out there?");
}, { timeout: Infinity });
});

0 comments on commit 742aa6f

Please sign in to comment.