chrome_for_testing_manager/
lib.rs1mod cache;
2pub mod chromedriver;
3mod download;
4pub mod mgr;
5pub mod port;
6pub mod session;
7
8pub mod prelude {
9    pub use crate::chromedriver::Chromedriver;
10    pub use crate::mgr::ChromeForTestingManager;
11    pub use crate::mgr::VersionRequest;
12    pub use crate::port::Port;
13    pub use crate::port::PortRequest;
14    pub use crate::session::Session;
15    pub use chrome_for_testing::api::channel::Channel;
16    pub use chrome_for_testing::api::version::Version;
17}
18
19#[cfg(test)]
20mod tests {
21    use crate::prelude::*;
22    use assertr::prelude::*;
23    use serial_test::serial;
24    use thirtyfour::ChromiumLikeCapabilities;
25
26    #[ctor::ctor]
27    fn init_test_tracing() {
28        tracing_subscriber::fmt().with_test_writer().try_init().ok();
29    }
30
31    #[tokio::test]
32    #[serial]
33    #[cfg(feature = "thirtyfour")]
34    async fn latest_stable() -> anyhow::Result<()> {
35        let chromedriver = Chromedriver::run_latest_stable().await?;
36
37        chromedriver
38            .with_session(async |session| {
39                session.goto("https://www.google.com").await?;
40                let url = session.current_url().await?;
41                assert_that(url).has_display_value("https://www.google.com/");
42                Ok(())
43            })
44            .await?;
45
46        chromedriver.terminate().await?;
47
48        Ok(())
49    }
50
51    #[tokio::test]
52    #[serial]
53    #[cfg(feature = "thirtyfour")]
54    async fn latest_stable_with_caps() -> anyhow::Result<()> {
55        let chromedriver = Chromedriver::run_latest_stable().await?;
56
57        chromedriver
58            .with_custom_session(
59                |caps| caps.unset_headless(),
60                async |session| {
61                    session.goto("https://www.google.com").await?;
62                    let url = session.current_url().await?;
63                    assert_that(url).has_display_value("https://www.google.com/");
64                    Ok(())
65                },
66            )
67            .await?;
68
69        chromedriver.terminate().await?;
70
71        Ok(())
72    }
73}