-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathselenium.test.js
42 lines (30 loc) · 1.11 KB
/
selenium.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import path from "node:path";
import selenium from "selenium-webdriver";
import chrome from "selenium-webdriver/chrome.js";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import util from "../src/util.js";
describe("run", async function () {
/**
* @type {chrome.Driver | undefined}
*/
let driver = undefined;
beforeAll(async function () {
const options = new chrome.Options();
const seleniumArgs = [
`--nwapp=${path.resolve("test", "fixture" , "app")}`,
"--headless=new",
];
options.addArguments(seleniumArgs);
const chromedriverPath = await util.findpath("chromedriver", { flavor: 'sdk' });
const service = new chrome.ServiceBuilder(chromedriverPath).build();
driver = chrome.Driver.createSession(options, service);
});
it("should run post install", async function () {
const textElement = await driver.findElement(selenium.By.id('test'));
const text = await textElement.getText();
expect(text).toEqual('Hello, World! Is anyone out there?');
}, { timeout: Infinity });
afterAll(async function () {
await driver.quit();
});
});