playwright_dart 0.1.2 copy "playwright_dart: ^0.1.2" to clipboard
playwright_dart: ^0.1.2 copied to clipboard

A complete Dart port of Playwright — fast, reliable browser automation for Chromium, Firefox, and WebKit with full API parity to Node.js v1.60.0.

example/main.dart

// Example demonstrating basic Playwright Dart usage.
//
// This script launches Chromium, navigates to a page, interacts with
// elements using the Locator API, evaluates JavaScript, and takes a screenshot.
import 'package:playwright_dart/playwright_dart.dart';

void main() async {
  // Create a Playwright instance (auto-downloads driver if needed)
  final playwright = await Playwright.create();

  // Launch a Chromium browser
  final browser = await playwright.chromium.launch();

  // Create a new page
  final page = await browser.newPage();

  // Set page content with interactive elements
  await page.setContent('''
    <html>
      <head><title>Playwright Dart Example</title></head>
      <body>
        <h1 id="header">Hello World</h1>
        <button id="btn">Click Me</button>
        <input type="text" id="name" placeholder="Enter your name" />
        <select id="dropdown">
          <option value="opt1">Option 1</option>
          <option value="opt2">Option 2</option>
        </select>
      </body>
    </html>
  ''');

  // Get the page title
  final title = await page.title();
  print('Page title: $title');

  // Use Locator API for interactions
  await page.locator('#btn').click();
  print('Button clicked!');

  await page.locator('#name').fill('Playwright Dart');
  print('Input filled!');

  final selected = await page.locator('#dropdown').selectOption('opt2');
  print('Selected: $selected');

  // Evaluate JavaScript
  final result = await page.mainFrame.evaluate('document.title');
  print('Evaluated title: $result');

  // Clean up
  await browser.close();
  print('Done!');
}
0
likes
150
points
--
downloads

Publisher

verified publishermrcrbrth.my.id

A complete Dart port of Playwright — fast, reliable browser automation for Chromium, Firefox, and WebKit with full API parity to Node.js v1.60.0.

Homepage
Repository (GitHub)
View/report issues

Topics

#testing #browser #automation #e2e #playwright

License

MIT (license)

Dependencies

archive, http, path, yaml

More

Packages that depend on playwright_dart