con un clic
web-test-wallet-setup
// Set up MetaMask wallet extension for Web3 DApp testing - download extension, import wallet from private key. Run at test start if tests/config.yaml has web3.enabled=true.
// Set up MetaMask wallet extension for Web3 DApp testing - download extension, import wallet from private key. Run at test start if tests/config.yaml has web3.enabled=true.
Generate persistent test cases from project analysis, or add individual test cases interactively. Supports full project analysis or adding single test cases via prompt description with browser exploration.
Execute tests from persistent test cases. Reads ./tests/ directory, runs cleanup, wallet setup (if Web3), executes tests, and generates report.
Analyze ANY web project - detect if Web3 DApp, research dependencies via WebSearch, understand business functions from code AND UI screenshots, generate test requirements.
Connect wallet to Web3 DApp - navigate to DApp, click Connect Wallet, approve in MetaMask popup, verify connection. Can be used as a test case or as a precondition for other tests.
Clean up test sessions - kill browsers, stop dev servers, free ports, and optionally remove test data. Use this BEFORE starting new tests or AFTER completing tests.
Generate test report with clear visual indicators - ✅ for pass, ❌ for fail. Summarize results, document failures, provide recommendations.
| name | web-test-wallet-setup |
| description | Set up MetaMask wallet extension for Web3 DApp testing - download extension, import wallet from private key. Run at test start if tests/config.yaml has web3.enabled=true. |
| license | MIT |
| compatibility | Node.js 18+, Playwright |
| metadata | {"author":"AI Agent","version":"2.1.0"} |
| allowed-tools | Bash Read |
Set up MetaMask wallet extension for Web3 DApp testing.
Updated for MetaMask v13 with new UI support.
This skill should be executed automatically at the start of testing when:
# In tests/config.yaml
web3:
enabled: true # <-- If this is true, run wallet-setup FIRST
Execution timing:
tests/.test-env file with WALLET_PRIVATE_KEY already existstests/config.yaml exists with web3.enabled: trueSKILL_DIR="<path-to-this-skill>"
# Step 1: Download wallet extension
node $SKILL_DIR/scripts/wallet-setup-helper.js wallet-setup
# Step 2: Initialize wallet (reads WALLET_PRIVATE_KEY from .test-env, writes WALLET_PASSWORD)
node $SKILL_DIR/scripts/wallet-setup-helper.js wallet-init --wallet --headed
WALLET_PRIVATE_KEY from tests/.test-envWALLET_PASSWORD to tests/.test-env (auto-generated if not set)Technical Note: The private key (256 bits) is used as entropy to generate a 24-word BIP-39 mnemonic. This mnemonic, when imported into MetaMask, creates a wallet where the first derived account corresponds exactly to the original private key.
SKILL_DIR="<path-to-this-skill>"
# Download and install MetaMask wallet extension
node $SKILL_DIR/scripts/wallet-setup-helper.js wallet-setup
What this does:
./test-output/extensions/metamask/Expected Output:
{
"success": true,
"message": "MetaMask Wallet v13.13.1 installed successfully",
"extensionPath": "./test-output/extensions/metamask"
}
SKILL_DIR="<path-to-this-skill>"
# Initialize wallet (reads from .test-env automatically)
node $SKILL_DIR/scripts/wallet-setup-helper.js wallet-init --wallet --headed
What this does:
WALLET_PRIVATE_KEY from tests/.test-envWALLET_PASSWORD to .test-envExpected Output:
{
"success": true,
"message": "Wallet initialization completed successfully",
"nextStep": "Use web-test-wallet-connect to connect wallet to DApp"
}
The .test-env file does not exist or does not contain the private key. Ensure tests/.test-env exists with WALLET_PRIVATE_KEY before running this skill.
Check network connection. The script downloads from GitHub releases.
./test-output/screenshots/ for error screenshotsIf wallet was previously set up, it will be unlocked automatically using the password from .test-env.
To reset:
rm -rf ./test-output/chrome-profile/
node $SKILL_DIR/scripts/wallet-setup-helper.js wallet-setup
node $SKILL_DIR/scripts/wallet-setup-helper.js wallet-init --wallet --headed
<project-root>/
├── tests/
│ └── .test-env # Reads WALLET_PRIVATE_KEY, writes WALLET_PASSWORD
└── test-output/
├── extensions/
│ └── metamask/ # MetaMask extension files
├── chrome-profile/ # Browser profile with wallet state
└── screenshots/ # Setup screenshots for debugging
After wallet setup is complete:
tests/test-cases.yamlweb-test-cleanup without --keep-data to reset walletThe script supports both the new MetaMask v13 UI and older versions:
New UI Flow (v13+):
keyboard.type() for proper event handling)Key Selectors (v13):
button:has-text("I have an existing wallet")button:has-text("Import using Secret Recovery Phrase")textarea (NOT 12 separate inputs)button:has-text("Continue")input[type="password"] (2 inputs)button:has-text("Create password")[data-testid="account-menu-icon"][data-testid="multichain-account-menu-popover-action-button"][data-testid="multichain-account-menu-popover-add-imported-account"]#private-key-box