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