Testing Metamask | UIlicious Docs (2024)

MetaMask is a cryptocurrency wallet that enables users to store Ether and other ERC-20 tokens.

If you are testing a Web3 application that requires interacting with a MetaMask wallet, UIlicious allows you to run tests on browsers installed with the MetaMask extension.

Note that you need to have the "Metamask Test Runner" Add-On in your subscription to be able to run tests on browsers configured with the MetaMask extension.

On the "Run" toolbar, select "Metamask" in the Browser dropdown, and press "Run" to run a test on a browser that comes installed with MetaMask.

Testing Metamask | UIlicious Docs (1)

Whenever the test is started, the MetaMask will always be the active tab opened, and starts with the "Getting Started" screen.

Testing Metamask | UIlicious Docs (2)

# MetaMask Plugin

UIlicious also provides a plugin to simplify setting up MetaMask for testing.

# Importing the plugin

First, you need to import the plugin using the TEST.loadPlugin to import "metamask". You can assign the imported module to any variable. In this guide, we'll name the imported plugin "metamask".

let metamask = TEST.loadPlugin("metamask")

Once the plugin is loaded, you can use the setup function to create a wallet, import an existing wallet, switch network, and manually add a network.

# Create wallet and use default network

By default, if you run the setup function without passing options, Metamask will be configured to create a new wallet and use the default network, which is Ethereum Mainnet.

// run the setup with no custom optionsmetamask.setup() // this will create a wallet and use the default network.

If you wish to reveal the passphase of the created wallet, you can view the screenshot taken at the "Confirm Secret Recovery Phrase" screen.

You may also read the passphase using the function getPassphase and print the passphase to the test report using TEST.log.info, as such:

// setup with a new walletmetamask.setup() // print the wallet passphrase to the test reportTEST.log.info("passphrase: ", metamask.getPassphrase())

# Import wallet

If you wish to import an existing wallet instead of creating a new wallet, you can run the setup function and provide the wallet's secret recovery phrase in the wallet.passphrase option:

// import an existing wallet using the recovery passphrasemetamask.setup({wallet: {passphrase: "<WALLET SECRET RECOVERY PHRASE>"}})

We highly recommend against importing any wallets that contain real value. You should use throwaway wallets from testnets instead.

# Switch network

By default, Metamask will use the Ethereum Mainnet. However, if you wish to use another network from MetaMask's predefined list of networks, you can run the setup function and provide the name of the network you want to switch to in network.name. The example below a setup that imports a wallet and switches to the "Aurora Mainnet".

metamask.setup({wallet: {passphrase: "<WALLET SECRET RECOVERY PHRASE>" // import a wallet},network : {name: "Aurora Mainnet" // switch to another network}})
Testing Metamask | UIlicious Docs (3)

If you have already ran the setup function once to create or import the wallet, and wish to switch the network at a later part of the test, you can use the addNetwork function instead using the same options.

metamask.addNetwork({network : {name: "Aurora Mainnet" // switch to another network}})

# Add a network manually

If you wish to use a custom network, you can run the setup function and provide the details of the network you want to add manually:

metamask.setup({network : {name : "BuildBear",rpcURL: "https://rpc.buildbear.io/example",chainID: 1,currencySymbol: "NAT",explorerURL: "http://explorer.buildbear.io/example"}})

Contact your testnet provider for the network details such as rpcURL, and explorerURL.

Testing Metamask | UIlicious Docs (4)

If you have already ran the setup function once to create or import the wallet, and wish to add the network at a later part of the test, you can use the addNetwork function instead using the same options.

metamask.addNetwork({network : {name : "BuildBear",rpcURL: "https://rpc.buildbear.io/example",chainID: 1,currencySymbol: "NAT",explorerURL: "http://explorer.buildbear.io/example"}})

# Opening the Metamask settings

Whenever the test is started, the MetaMask settings will always be the active tab opened, starting with the "Getting Started" page. If the test has navigated away to other pages, and you wish to open the MetaMask settings page, you can use the open function.

// Opens the MetaMask settings pagemetamask.open() 

Sometimes when opening the MetaMask settings page, MetaMask might ask you to unlock the device if too much time has passed. You can get the device password generated for the current test session using the getDevicePassword function.

// Opens the MetaMask settings pagemetamask.open() // Fill the password and unlock the settings pageI.fill("Password", metamask.getDevicePassword())I.click("Unlock")
Testing Metamask | UIlicious Docs (2024)
Top Articles
foreign exchange market: Latest News & Videos, Photos about foreign exchange market | The Economic Times - Page 1
Long-Term Investments: Definition, Strategies, Types, Pros & Cons
Harry Potter: Magical Portraits, Explained
Myusu Canvas
[PDF] Latin America/US Hispanic Media - Free Download PDF
Missed Connections Inland Empire
Hendersonville (Tennessee) – Travel guide at Wikivoyage
GIF by Barstool Sports - Find & Share on GIPHY
Miami Valley Harness Picks
Safelite Paris Tn
los angeles cars & trucks - by owner "used cars" - craigslist
Devotion Showtimes Near Amc Hoffman Center 22
Www.yourtotalrewards/Carrier
7 Best Jointers Reviewed, Tested and Compared in 2024 | House Grail
Craigslist Cars Lansing Michigan
The Autopsy Report: Overview, Suggested Autopsy Report Headings, An Overview of the Autopsy Report
9-1-1 Kidnapped Boy Episode Cast
Subway Surfers Unblocked Wtf
Watch ESPN - Stream Live Sports & ESPN Originals
Santa Barbara Craigs List
24 Hour Drive Thru Car Wash Near Me
Bangor Daily Sports
Odawa Hypixel
3Si Tracker Login
Ficoforum
Clafi Arab
Stardew Potato
Cash App Paid Screenshot
Chickasaw Garbage And Sewer
Syracuse Deadline
Craigslist Yard Sales Jacksonville Fl
Maurices Thanks Crossword Clue
Tour 2024 | Titleist Ambassadors and PGA Players | Titleist
Craigslist Musicians Delaware
Synonym For Saint Word Craze
Ixl Ld Northeast
United Tool Rentals Near Me
Fleet Feet Sports Johnson City Tn
NRA Training
In The Heights Wiki
Beginner S Guide Grand Summoners How To Beat Pulling The Strings
Amerideck Motorcycle Lift Cost
Full Cast Of Red
The Second Amendment Bible
What Time Is First Light Tomorrow Morning
Cornerstone Fence Edmond
Ice Dodo Unblocked 76
Kobalt Kst 180-06 Parts
Miami Valley Harness Picks
Driving Directions To Gamestop Near Me
Apartment living? How to cold plunge in small spaces
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 5784

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.