selenium-metamask
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

selenium-metamask

MetaMask wrapper for selenium webdriver API

(Chrome/Firefox supported only)

Requirements

  • selenium ^4.1
  • webdriver ^4.1

Installation

npm install selenium-metamask

Implemented actions

  • Authorization
  • Importing account
  • Creation account
  • Switching account
  • Adding network
  • Switching network
  • Getting account address

Usage

import { Builder, until } from "selenium-webdriver"
import { Options } from "selenium-webdriver/chrome"
import { Loader, MetaMask } from "selenium-metamask"

async function init() {
    const builder = new Builder()
        .withCapabilities({
            'goog:chromeOptions': {
                excludeSwitches: ['enable-automation', 'useAutomationExtension'],
            },
        })
        .forBrowser('chrome')
        .usingServer('http://localhost:4444/')
    const loader = new Loader(builder)

    loader.loadChromeExtension(new Options())

    const driver = builder.build()
    const metaMask = new MetaMask(driver, until)
    const session = await metaMask.login('seed phrase')
    await session.addNetwork({
        name: 'NetworkName',
        chainIdentifier: '123',
        explorerUrl: 'https://explorer.example.com',
        rpcUrl: 'https://rpc.example.com',
        symbol: 'EXAMPLE',
    })
    await session.importAccount('private key')

    // Other tests
}

Readme

Keywords

none

Package Sidebar

Install

npm i selenium-metamask

Weekly Downloads

2

Version

3.0.1

License

MIT

Unpacked Size

35.6 MB

Total Files

18

Last publish

Collaborators

  • 22116