launch method
Launches the browser with the given configuration
Implementation
Future<HeadlessBrowser> launch(HeadlessBrowserConfig config) async {
// Create a new browser with the given configuration
final browser = HeadlessBrowser(config: config, logger: _logger);
// Initialize the browser
await browser.initialize();
// Navigate to the URL if provided
if (config.url != null) {
await browser.navigateTo(
config.url!,
headers: config.headers,
timeoutMillis: config.timeout,
);
// Wait for network idle if configured
if (config.waitForNetworkIdle) {
await browser.waitForNetworkIdle();
}
// Wait for DOM content loaded if configured
if (config.waitForDomContentLoaded) {
await browser.waitForDomContentLoaded();
}
}
return browser;
}