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
Ripple Analyst Predicts XRP Price to Reach $20 by 2026, Citing Five Factors By The News Crypto
WHAT ARE THE 5 NEGOTIATION STYLES? What is best for you?
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
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.