1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00
_/playwright-rust/main.rs

19 lines
661 B
Rust
Raw Normal View History

2024-08-26 11:11:06 +09:00
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(())
}