Repository navigation
Replies: 3 comments 3 replies
|
Just a simple example of what #55 (comment) discussed here linked to sycamore repo and docs may be enough. |
0 replies
|
I may be horribly out of date, but Perseus (now-mostly-outdated fullstack framework for Sycamore) had a lot of end-to-end testing built with |
1 reply
const DRIVER_URL: &str = "http://127.0.0.1:4444";
// Singleton tauri-driver process, started once for all tests.
static DRIVER: LazyLock<Option<Child>> = LazyLock::new(|| {
println!("running driver...");
let bin = which::which("tauri-driver").ok()?;
let mut child = std::process::Command::new(&bin).args(["--port", "4444"]).spawn().ok()?;
println!("spawned driver {bin:?}...");
// Give tauri-driver + WebKitWebDriver time to boot
std::thread::sleep(Duration::from_secs(5));
println!("waiting for driver...");
// Check if tauri-driver is still alive (exits immediately if WebKitWebDriver is missing)
match child.try_wait() {
Ok(Some(status)) => {
eprintln!("tauri-driver exited with {status}");
None
},
Ok(None) => Some(child),
Err(error) => {
eprintln!("error occured during driver run: {error}");
None
},
}
});
pub async fn with_client() -> Client {
if DRIVER.is_none() {
std::thread::sleep(Duration::from_secs(5));
panic!("tauri-driver not running (see stderr for details)");
} else {
println!("running dizola app");
let app_bin = std::env::var("DIZOLA_APP_BIN").unwrap_or_else(|_| "target/debug/dizola-app".to_string());
let mut caps = Map::<String, Value>::new();
let mut tauri_opts = Map::<String, Value>::new();
tauri_opts.insert("application".to_string(), json!(app_bin));
caps.insert("tauri:options".to_string(), Value::Object(tauri_opts));
println!("building client for our app");
let client = ClientBuilder::native()
.capabilities(caps)
.connect(DRIVER_URL)
.await
.expect("failed to connect");
client
.goto("tauri://localhost")
.await
.expect("failed to navigate to initial host");
client
.wait()
.for_element(Locator::Css(".app"))
.await
.expect("Sycamore .app div not found - app didn't mount");
std::thread::sleep(Duration::from_millis(500));
client
}
}a little bit of WIP monster that I made. Currently it's succesfully running the infrastructure, but I still have issues on how to connect tauri and fantoccini. Will keep this thread updated until I solve it |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello there, I would like to ask if someone has succeed in configuring UI automated tests using Sycamore (as part of tauri app) and webdriver? As Tauri guide and examples focuses on npm based frontends, it is a little bit non-trivial and I am looking for existing examples without success at the moment(
All reactions