21 releases

0.0.20 Aug 20, 2022
0.0.19 Nov 27, 2021
0.0.18 May 25, 2021
0.0.16 Apr 25, 2021
0.0.5 Mar 29, 2021

#5 in #headless

Download history 34/week @ 2023-12-13 17/week @ 2023-12-20 18/week @ 2023-12-27 51/week @ 2024-01-03 67/week @ 2024-01-10 229/week @ 2024-01-17 298/week @ 2024-01-24 97/week @ 2024-01-31 97/week @ 2024-02-07 64/week @ 2024-02-14 154/week @ 2024-02-21 89/week @ 2024-02-28 90/week @ 2024-03-06 106/week @ 2024-03-13 195/week @ 2024-03-20 355/week @ 2024-03-27

754 downloads per month

MIT/Apache

1MB
14K SLoC

🎭 Playwright for Rust

crates.io docs.rs MIT OR Apache-2.0 CI codecov

Playwright is a rust library to automate Chromium, Firefox and WebKit built on top of Node.js library.

Installation

[dependencies]
playwright = "0.0.18"

Usage

use playwright::Playwright;

#[tokio::main]
async fn main() -> Result<(), playwright::Error> {
    let playwright = Playwright::initialize().await?;
    playwright.prepare()?; // Install browsers
    let chromium = playwright.chromium();
    let browser = chromium.launcher().headless(true).launch().await?;
    let context = browser.context_builder().build().await?;
    let page = context.new_page().await?;
    page.goto_builder("https://example.com/").goto().await?;

    // Exec in browser and Deserialize with serde
    let s: String = page.eval("() => location.href").await?;
    assert_eq!(s, "https://example.com/");
    page.click_builder("a").click().await?;
    Ok(())
}

Async runtimes

These runtimes have passed tests. You can disable tokio, the default feature, and then choose another.

Incompatibility

Functions do not have default arguments in rust. Functions with two or more optional arguments are now passed with the builder pattern.

Playwright Driver

Playwright is designed as a server-client. All playwright client dependent on the driver: zip of core js library and Node.js. Application uses this library will be bundled the driver into rust binary at build time. There is an overhead of unzipping on the first run.

NOTICE

playwright-rust redistributes Playwright licensed under the Apache 2.0.
Playwright has NOTICE:
"""
Playwright
Copyright (c) Microsoft Corporation

This software contains code derived from the Puppeteer project (https://github.com/puppeteer/puppeteer),
available under the Apache 2.0 license (https://github.com/puppeteer/puppeteer/blob/master/LICENSE).
"""

Browser automation in rust

Other languages

Dependencies

~8–23MB
~307K SLoC