This package is created to automate metamask wallet extension using selenium webdriver.
pip install ./selenium_metamask_automation
or
pip install -i https://test.pypi.org/simple/ selenium-metamask-automation
Check if the package exists
pip list
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”
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")
selenium_metamask_automation.metamaskSetup(arg1, arg2)
arg1 : seed phrase of wallet arg2: password of wallet
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
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()
Confirm:
selenium_metamask_automation.confirmApprovalFromMetamask()
Reject:
selenium_metamask_automation.rejectApprovalFromMetamask()
Confirm:
selenium_metamask_automation.confirmTransactionFromMetamask()
Reject:
selenium_metamask_automation.rejectTransactionFromMetamask()
selenium_metamask_automation.addToken(arg)
arg: contract address of token
signConfirm:
selenium_metamask_automation.signConfirm()
signReject:
selenium_metamask_automation.signReject()
pip list shows the package “selenium_metamask_automation”
but your IDE does not detect the package
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