aboutsummaryrefslogtreecommitdiffstats
path: root/test/runner/selenium/runSelenium.js
blob: 848db36c72b68954b3154e223369e7abf4b3b1b6 (plain)
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
import createDriver from "./createDriver.js";

export async function runSelenium(
	url,
	{ browser },
	{ debug, headless, verbose } = {}
) {
	if ( debug && headless ) {
		throw new Error( "Cannot debug in headless mode." );
	}

	const driver = await createDriver( {
		browserName: browser,
		headless,
		verbose
	} );

	try {
		await driver.get( url );
		await driver.executeScript(
`return new Promise( ( resolve ) => {
	QUnit.on( "runEnd", resolve );
} )`
		);
	} finally {
		if ( !debug || headless ) {
			await driver.quit();
		}
	}
}