diff --git a/src/browser.rs b/src/browser.rs index 777ab0da..a3979960 100644 --- a/src/browser.rs +++ b/src/browser.rs @@ -79,6 +79,16 @@ impl Browser { /// /// If the URL is a http(s) URL, it will first attempt to retrieve the Websocket URL from the `json/version` endpoint. pub async fn connect(url: impl Into) -> Result<(Self, Handler)> { + Self::connect_with_config(url, HandlerConfig::default()).await + } + + // Connect to an already running chromium instance with a given `HandlerConfig`. + /// + /// If the URL is a http(s) URL, it will first attempt to retrieve the Websocket URL from the `json/version` endpoint. + pub async fn connect_with_config( + url: impl Into, + config: HandlerConfig, + ) -> Result<(Self, Handler)> { let mut debug_ws_url = url.into(); if debug_ws_url.starts_with("http") { @@ -121,29 +131,6 @@ impl Browser { let (tx, rx) = channel(1); - let fut = Handler::new(conn, rx, HandlerConfig::default()); - let browser_context = fut.default_browser_context().clone(); - - let browser = Self { - sender: tx, - config: None, - child: None, - debug_ws_url, - browser_context, - }; - Ok((browser, fut)) - } - - // Connect to an already running chromium instance via websocket with HandlerConfig - pub async fn connect_with_config( - debug_ws_url: impl Into, - config: HandlerConfig, - ) -> Result<(Self, Handler)> { - let debug_ws_url = debug_ws_url.into(); - let conn = Connection::::connect(&debug_ws_url).await?; - - let (tx, rx) = channel(1); - let fut = Handler::new(conn, rx, config); let browser_context = fut.default_browser_context().clone();