pub struct Browser { /* private fields */ }Implementations§
Source§impl Browser
impl Browser
Sourcepub fn builder() -> BrowserBuilder
pub fn builder() -> BrowserBuilder
Examples found in repository?
examples/youtube_test.rs (line 7)
4async fn main() {
5 println!("=== YouTube Test ===\n");
6
7 let browser = Browser::builder()
8 .headful()
9 .profile(7, 777)
10 .build()
11 .await
12 .expect("launch failed");
13
14 let page = browser.new_page("https://www.youtube.com").await.expect("nav failed");
15 page.wait(3000).await;
16
17 let title = page.js("document.title").await.unwrap_or_default();
18 let url = page.url().await.unwrap_or_default();
19 println!("Title: {title}");
20 println!("URL: {url}");
21
22 println!("\nBrowser open. Ctrl+C to exit.");
23 loop {
24 tokio::time::sleep(std::time::Duration::from_secs(60)).await;
25 }
26}More examples
examples/smoke_test.rs (line 7)
4async fn main() {
5 println!("=== Smoke Test ===\n");
6
7 let browser = Browser::builder()
8 .headful()
9 .profile(7, 777)
10 .build()
11 .await
12 .expect("launch failed");
13
14 let page = browser.new_page("about:blank").await.expect("page failed");
15
16 let checks = &[
17 ("webdriver", "navigator.webdriver.toString()"),
18 ("timezone", "Intl.DateTimeFormat().resolvedOptions().timeZone"),
19 ("cores", "navigator.hardwareConcurrency.toString()"),
20 ("screen", "screen.width+'x'+screen.height"),
21 ("UA", "navigator.userAgent"),
22 ];
23 for (name, expr) in checks {
24 let val = page.js(expr).await.unwrap_or_default();
25 println!("{name}: {val}");
26 }
27
28 println!("\nBrowser open. Ctrl+C to exit.");
29 loop {
30 tokio::time::sleep(std::time::Duration::from_secs(60)).await;
31 }
32}Sourcepub async fn connect(ws_url: &str) -> Result<Self>
pub async fn connect(ws_url: &str) -> Result<Self>
Connect to an already-running Chrome at ws_url.
Sourcepub async fn new_page(&self, url: &str) -> Result<Page>
pub async fn new_page(&self, url: &str) -> Result<Page>
Open a new tab and navigate to URL.
Examples found in repository?
examples/youtube_test.rs (line 14)
4async fn main() {
5 println!("=== YouTube Test ===\n");
6
7 let browser = Browser::builder()
8 .headful()
9 .profile(7, 777)
10 .build()
11 .await
12 .expect("launch failed");
13
14 let page = browser.new_page("https://www.youtube.com").await.expect("nav failed");
15 page.wait(3000).await;
16
17 let title = page.js("document.title").await.unwrap_or_default();
18 let url = page.url().await.unwrap_or_default();
19 println!("Title: {title}");
20 println!("URL: {url}");
21
22 println!("\nBrowser open. Ctrl+C to exit.");
23 loop {
24 tokio::time::sleep(std::time::Duration::from_secs(60)).await;
25 }
26}More examples
examples/smoke_test.rs (line 14)
4async fn main() {
5 println!("=== Smoke Test ===\n");
6
7 let browser = Browser::builder()
8 .headful()
9 .profile(7, 777)
10 .build()
11 .await
12 .expect("launch failed");
13
14 let page = browser.new_page("about:blank").await.expect("page failed");
15
16 let checks = &[
17 ("webdriver", "navigator.webdriver.toString()"),
18 ("timezone", "Intl.DateTimeFormat().resolvedOptions().timeZone"),
19 ("cores", "navigator.hardwareConcurrency.toString()"),
20 ("screen", "screen.width+'x'+screen.height"),
21 ("UA", "navigator.userAgent"),
22 ];
23 for (name, expr) in checks {
24 let val = page.js(expr).await.unwrap_or_default();
25 println!("{name}: {val}");
26 }
27
28 println!("\nBrowser open. Ctrl+C to exit.");
29 loop {
30 tokio::time::sleep(std::time::Duration::from_secs(60)).await;
31 }
32}Get all browser cookies.
Sourcepub fn cdp(&self) -> &CdpBrowser
pub fn cdp(&self) -> &CdpBrowser
Access underlying chromiumoxide Browser for raw CDP.
Auto Trait Implementations§
impl Freeze for Browser
impl !RefUnwindSafe for Browser
impl Send for Browser
impl Sync for Browser
impl Unpin for Browser
impl UnsafeUnpin for Browser
impl !UnwindSafe for Browser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more