main.rs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. //! [![](https://github.com/tauri-apps/tauri/raw/dev/.github/splash.png)](https://tauri.app)
  5. //!
  6. //! Cross-platform WebDriver server for Tauri applications.
  7. //!
  8. //! This is a [WebDriver Intermediary Node](https://www.w3.org/TR/webdriver/#dfn-intermediary-nodes) that wraps the native WebDriver server for platforms that [Tauri](https://github.com/tauri-apps/tauri) supports. Your WebDriver client will connect to the running `tauri-driver` server, and `tauri-driver` will handle starting the native WebDriver server for you behind the scenes. It requires two separate ports to be used since two distinct [WebDriver Remote Ends](https://www.w3.org/TR/webdriver/#dfn-remote-ends) run.
  9. #![doc(
  10. html_logo_url = "https://github.com/tauri-apps/tauri/raw/dev/.github/icon.png",
  11. html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/.github/icon.png"
  12. )]
  13. #[cfg(any(target_os = "linux", windows))]
  14. mod cli;
  15. #[cfg(any(target_os = "linux", windows))]
  16. mod server;
  17. #[cfg(any(target_os = "linux", windows))]
  18. mod webdriver;
  19. #[cfg(not(any(target_os = "linux", windows)))]
  20. fn main() {
  21. println!("tauri-driver is not supported on this platform");
  22. std::process::exit(1);
  23. }
  24. #[cfg(any(target_os = "linux", windows))]
  25. fn main() {
  26. let args = pico_args::Arguments::from_env().into();
  27. // start the native webdriver on the port specified in args
  28. let mut driver = webdriver::native(&args);
  29. let driver = driver
  30. .spawn()
  31. .expect("error while running native webdriver");
  32. // start our webdriver intermediary node
  33. if let Err(e) = server::run(args, driver) {
  34. eprintln!("error while running server: {}", e);
  35. std::process::exit(1);
  36. }
  37. }