-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilder.test.js
58 lines (45 loc) · 1.61 KB
/
builder.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { equal } from 'node:assert';
import path from 'node:path';
import process from 'node:process';
import { findpath } from 'nw';
import selenium from 'selenium-webdriver';
import chrome from 'selenium-webdriver/chrome.js';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
describe('NW.js Selenium Builder test suite', async () => {
let driver = undefined;
/* Setup Selenium driver. */
beforeAll(async function () {
/* Initialise Chrome options */
const options = new chrome.Options();
const seleniumArguments = [
'nwapp=' + path.resolve('js', 'selenium', 'builder')
];
/* Run in headless mode when in CI environment. */
if (process.env.CI) {
seleniumArguments.push('headless=new');
}
options.addArguments(seleniumArguments);
const nwPath = await findpath('nwjs', { flavor: 'sdk' });
options.setChromeBinaryPath(nwPath);
/* Create a new session using the Chromium options and DriverService defined above. */
driver = new selenium
.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
});
/**
* Get text via element's ID and assert it is equal.
*/
it('Hello, World! text by ID', async function () {
const textElement = await driver.findElement(selenium.By.id('test'));
const text = await textElement.getText();
equal(text, 'Hello, World!');
}, { timeout: 30000 });
/**
* Quit Selenium driver.
*/
afterAll(() => {
driver.quit();
});
});