mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
32 lines
566 B
JavaScript
32 lines
566 B
JavaScript
|
import chalk from "chalk";
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|