Web3 wallets for Playwright.
This library provides methods for interacting with Web3 wallets using Playwright.
npm install -D w3walletsMetaMask, Backpack, and Polkadot{.js} wallets are currently supported.
npx w3wallets backpack polkadotJSThe unzipped files should be stored in the .w3wallets/<wallet-name> directory. Add them to .gitignore.
Install the required wallets into Chromium using withWallets.
// your-fixture.ts
import { withWallets } from "w3wallets";
import { test as base } from "@playwright/test";
export const test = withWallets(
  base,
  "backpack",
  "polkadotJS",
).extend<BaseFixture>({
  magic: (_, use) => use(42),
});
type BaseFixture = {
  magic: number;
};
export { expect } from "@playwright/test";Most commonly, you will use the following methods:
- onboard: to set up your wallet
- approve: for operations that confirm actions
- deny: for actions that reject or cancel operations
import { test } from "./your-fixture";
test("Can use wallet", async ({ page, backpack }) => {
  const privateKey =
    "4wDJd9Ds5ueTdS95ReAZGSBVkjMcNKbgZk47xcmqzpUJjCt7VoB2Cs7hqwXWRnopzXqE4mCP6BEDHCYrFttEcBw2";
  await backpack.onboard("Eclipse", privateKey);
});