1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-30 22:08:02 +00:00
_/playwright-rust/main.rs

18 lines
661 B
Rust

use playwright::Playwright;
#[tokio::main]
async fn main() -> Result<(), playwright::Error> {
let playwright = Playwright::initialize().await?;
playwright.prepare()?;
let chromium = playwright.chromium();
let browser = chromium.launcher().launch().await?;
let context = browser.context_builder().build().await?;
let page = context.new_page().await?;
page.goto_builder("https://example.com/").goto().await?;
let s: String = page.eval("() => location.href").await?;
println!("{}", s);
page.click_builder("a").click().await?;
let s: String = page.eval("() => location.href").await?;
println!("{}", s);
Ok(())
}