playwright_rs/api/connect_options.rs
1use std::collections::HashMap;
2
3/// Options for `BrowserType::connect`.
4#[derive(Debug, Clone, Default)]
5pub struct ConnectOptions {
6 /// Additional HTTP headers to send with the WebSocket handshake.
7 pub headers: Option<HashMap<String, String>>,
8 /// Slows down Playwright operations by the specified amount of milliseconds.
9 /// Useful so that you can see what is going on.
10 pub slow_mo: Option<f64>,
11 /// Maximum time in milliseconds to wait for the connection to be established.
12 /// Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
13 pub timeout: Option<f64>,
14}
15
16impl ConnectOptions {
17 /// Creates a new `ConnectOptions` with default values.
18 pub fn new() -> Self {
19 Self::default()
20 }
21
22 /// Set additional HTTP headers to send with the WebSocket handshake.
23 pub fn headers(mut self, headers: HashMap<String, String>) -> Self {
24 self.headers = Some(headers);
25 self
26 }
27
28 /// Set slow mo delay in milliseconds.
29 pub fn slow_mo(mut self, slow_mo: f64) -> Self {
30 self.slow_mo = Some(slow_mo);
31 self
32 }
33
34 /// Set connection timeout in milliseconds.
35 pub fn timeout(mut self, timeout: f64) -> Self {
36 self.timeout = Some(timeout);
37 self
38 }
39}