1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. //! The library provides interface for parsing and running `.side` files //! which are produced in comparable way as [`Selenium IDE`] does. //! //! # Example //! ``` //! use siderunner::{parse, Runner}; //! use thirtyfour::{DesiredCapabilities, WebDriver}; //! //! #[tokio::main] //! async fn main() { //! let wiki = std::fs::File::open("examples/wiki.side").expect("Can't open a side file"); //! let file = parse(wiki).expect("Failed parsing a file"); //! //! let client = WebDriver::new("http://localhost:4444", DesiredCapabilities::chrome()) //! .await //! .expect("can't connect to webdriver"); //! let mut runner = Runner::new(&client); //! runner.run(&file).await.expect("Fail in running first test"); //! //! assert_eq!( //! runner.get_data().get("slogan"), //! Some(&serde_json::json!("The Free Encyclopedia")), //! ); //! //! runner.close().await.expect("Error occured while closing webdriver"); //! } //! ``` //! //! [`Selenium IDE`]: https://www.selenium.dev/selenium-ide/ mod command; mod error; mod js_lib; mod parser; mod playground; mod playground_test; mod runner; mod validation; mod webdriver; pub use error::{ParseError, RunnerError}; pub use parser::{parse, Command, File, Test}; /// Runner responsible for running a [`Test`](./struct.Test.html) /// and collecting data. #[cfg(feature = "fantoccini_backend")] pub type Runner = runner::Runner<webdriver::fantoccini::Client>; /// Runner responsible for running a [`Test`](./struct.Test.html) /// and collecting data. #[cfg(feature = "thirtyfour_backend")] pub type Runner<'a> = runner::Runner<webdriver::thirtyfour::Client<'a>>; #[cfg(feature = "thirtyfour_backend")] impl<'a> Runner<'a> { /// Create a new runner pub fn new(client: &'a thirtyfour::WebDriver) -> Runner<'a> { Self::_new(webdriver::thirtyfour::Client(client)) } } #[cfg(feature = "fantoccini_backend")] impl Runner { /// Create a new runner pub fn new(client: fantoccini::Client) -> Runner { Self::_new(webdriver::fantoccini::Client(client)) } }