hahadaxia / selenium_metamask_automation

Python package to automate crypto wallet metamask

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

This package is created to automate metamask wallet extension using selenium webdriver.

To Install The Package:

pip install ./selenium_metamask_automation

Check if the package exists

pip list

Functions

1. To download the extension:

selenium_metamask_automation.downloadMetamaskExtension()

This function has to be run once before all functions to download the metamask extension. If you change the directory or create your python file somewhere else, this needs to be run first otherwise following exception will be thrown:

“Path to extension does not exist”

2. To launch the extension use the function below

selenium_metamask_automation.launchMetamaskExtension(args)

args: path to chrome webdriver

This function returns a value which contains the driver. You can retrieve it like:

driver = launchSeleniumWebdriver(r‘C:\Drivers\chromedriver_win32\chromedriver.exe’)

Now use can call any selenium method using this driver variable

driver.get("https://google.com")

3. To import wallet

selenium_metamask_automation.metamaskSetup(arg1, arg2)

arg1 : seed phrase of wallet arg2: password of wallet

4. To Change the metamask Network:

selenium_metamask_automation.changeMetamaskNetwork(arg)

arg: network name

The network names are mentioned below. On selecting any other network, it will throw an error.

  • Ethereum Mainnet
  • Ropsten Test Network
  • Kovan Test Network
  • Rinkeby Test Network
  • Goerli Test Network

4. To connect to any website use the function below:

selenium_metamask_automation.connectToWebsite()

In order to use this function, you have to visit the website first

driver.get("https://google.com")
selenium_metamask_automatiom.connectToWebsite()

6. For approval transactions:

Confirm:

selenium_metamask_automation.confirmApprovalFromMetamask()

Reject:

selenium_metamask_automation.rejectApprovalFromMetamask()

7. For transactions other than approval:

Confirm:

selenium_metamask_automation.confirmTransactionFromMetamask()

Reject:

selenium_metamask_automation.rejectTransactionFromMetamask()

8. To add token in your metamask wallet:

selenium_metamask_automation.addToken(arg)

arg: contract address of token

9. Sign:

signConfirm:

selenium_metamask_automation.signConfirm()

signReject:

selenium_metamask_automation.signReject()

Errors you might face:

pip list shows the package “selenium_metamask_automation” but your IDE does not detect the package

Solution:

Go to IDE settings > Python Interpreter

Change the path to C://ProgramFiles//Python//python.exe or in your case add the path where python.exe is installed

About

Python package to automate crypto wallet metamask

License:MIT License


Languages

Language:Python 98.2%Language:HTML 0.5%Language:CSS 0.5%Language:C++ 0.4%Language:PowerShell 0.1%Language:JavaScript 0.1%Language:Roff 0.0%Language:TeX 0.0%Language:C 0.0%Language:Classic ASP 0.0%Language:XSLT 0.0%Language:Shell 0.0%Language:Batchfile 0.0%Language:VBScript 0.0%