browser_use/browser/
mod.rs1pub mod config;
7pub mod session;
8
9pub use config::{ConnectionOptions, LaunchOptions};
10pub use session::BrowserSession;
11
12use crate::error::Result;
13
14pub fn init() -> Result<BrowserSession> {
16 BrowserSession::new()
17}
18
19pub fn init_with_options(options: LaunchOptions) -> Result<BrowserSession> {
21 BrowserSession::launch(options)
22}
23
24pub fn connect(ws_url: &str) -> Result<BrowserSession> {
26 BrowserSession::connect(ConnectionOptions::new(ws_url))
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn test_launch_options_export() {
35 let opts = LaunchOptions::new().headless(true);
36 assert!(opts.headless);
37 }
38
39 #[test]
40 fn test_connection_options_export() {
41 let opts = ConnectionOptions::new("ws://localhost:9222");
42 assert_eq!(opts.ws_url, "ws://localhost:9222");
43 }
44
45 #[test]
46 #[ignore]
47 fn test_init() {
48 let result = init();
49 assert!(result.is_ok());
50 }
51
52 #[test]
53 #[ignore]
54 fn test_init_with_options() {
55 let opts = LaunchOptions::new().headless(true).window_size(1024, 768);
56
57 let result = init_with_options(opts);
58 assert!(result.is_ok());
59 }
60}