Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Metamask automation with Selenium webdriver

I'm trying to get to a Dapp that needs Metamask extension to access it. I added it through chrome extension. I know how to add the extension to the chrome instance in selenium but I don't know how to add a password etc..Could anyone download Metamask and give me an example of how I could pass credentials through selenium using it?

 ChromeOptions options = new ChromeOptions();
 options.addArguments("--start-maximized");
 options.addExtensions(newFile("//Applications//chrome//MetaMask_v3.13.8.crx"));                
 driver = new ChromeDriver(options);
like image 543
gabe Avatar asked Jan 31 '18 02:01

gabe


1 Answers

Due to rather complex process of wallet info input in Metamask, it seems like the best way to get your test to work with Metamask extension is to start Chrome with defined profile directory use preconfigured Chrome profile:

# google-chrome -user-data-dir=/tmp/profile

then add Metamask extension and configure your wallet manually, and then add the correspondent argument to WebDriver options to use this profile instead of creating an empty one:

options.addArguments("user-data-dir=/tmp/profile");

Then, in test, you'll have to re-enter the Metamask's password and you'll all set.

like image 166
Sergey Lysenko Avatar answered Sep 21 '22 08:09

Sergey Lysenko