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.
Connect MetaMask wallet to a Web3 DApp.
┌────────────────────────────────────────────────────────────────────┐
│ ALWAYS USE dapp-click COMMAND FOR CLICKING BUTTONS! │
│ │
│ ✅ CORRECT (Use text/css/id selectors): │
│ dapp-click "Connect Wallet" --wallet --headed --keep-open │
│ dapp-click "MetaMask" --wallet --headed --keep-open │
│ dapp-click --css "button[data-testid='connect']" │
│ dapp-click --id "connect-btn" --wallet --headed --keep-open │
│ │
│ dapp-click uses text/CSS/ID selectors which are RELIABLE. │
│ It will: │
│ 1. Try text selector first (e.g., "Connect Wallet") │
│ 2. Try CSS selector (e.g., "button.connect-btn") │
│ 3. Try ID selector (e.g., "#connect-btn") │
│ │
└────────────────────────────────────────────────────────────────────┘
When tests/test-cases.yaml contains a wallet connection test case (e.g., WALLET-001), this skill is invoked to execute that test.
When a test case has preconditions: [WALLET-001 passed] or similar, the test executor should:
web3.enabled: true in configSKILL_DIR="<path-to-this-skill>"
# Navigate to DApp with wallet
node $SKILL_DIR/scripts/wallet-connect-helper.js wallet-navigate "http://localhost:3000" --wallet --headed --keep-open
# Click Connect Wallet button using text selector (PREFERRED METHOD)
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "Connect Wallet" --wallet --headed --keep-open
# If wallet modal appears, click MetaMask option
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "MetaMask" --wallet --headed --keep-open
# Approve connection in MetaMask popup
node $SKILL_DIR/scripts/wallet-connect-helper.js wallet-approve --wallet --headed --keep-open
# Verify connection
node $SKILL_DIR/scripts/wallet-connect-helper.js screenshot after-connect.jpg --wallet --headed --keep-open
SKILL_DIR="<path-to-this-skill>"
DAPP_URL="http://localhost:3000" # Your DApp URL
# Navigate to DApp with wallet extension loaded
node $SKILL_DIR/scripts/wallet-connect-helper.js wallet-navigate "$DAPP_URL" --wallet --headed --keep-open
Expected Output:
{
"success": true,
"url": "http://localhost:3000",
"screenshot": "dapp-home.jpg"
}
Use dapp-click with text selector - this is the PREFERRED method:
SKILL_DIR="<path-to-this-skill>"
# Try common button text labels
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "Connect Wallet" --wallet --headed --keep-open
# If that doesn't work, try other common labels:
# dapp-click "Connect" --wallet --headed --keep-open
# dapp-click "Sign In" --wallet --headed --keep-open
# dapp-click "Connect wallet" --wallet --headed --keep-open
Common Connect Button Labels (try in order):
If text selector fails, use CSS selector:
# Try CSS selectors
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click --css "button[data-testid='connect']" --wallet --headed --keep-open
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click --css ".connect-button" --wallet --headed --keep-open
ONLY as last resort - use coordinates with fallback:
# Take screenshot first to find coordinates
node $SKILL_DIR/scripts/wallet-connect-helper.js screenshot before-connect.jpg --wallet --headed --keep-open
# Then use dapp-click with fallback coordinates
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "Connect Wallet" --fallback-x 900 --fallback-y 50 --wallet --headed --keep-open
Many DApps show a wallet selection modal (Rainbow Kit, Privy, etc.):
Use dapp-click to select MetaMask option:
SKILL_DIR="<path-to-this-skill>"
# Try common MetaMask button labels
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "MetaMask" --wallet --headed --keep-open
# If that doesn't work, try other common labels:
# dapp-click "Injected Wallet" --wallet --headed --keep-open
# dapp-click "Browser Wallet" --wallet --headed --keep-open
# dapp-click "Injected" --wallet --headed --keep-open
Common Modal Options (try in order):
If text selector fails, use fallback coordinates:
# Take screenshot to find coordinates
node $SKILL_DIR/scripts/wallet-connect-helper.js screenshot wallet-modal.jpg --wallet --headed --keep-open
# Use dapp-click with fallback
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "MetaMask" --fallback-x 400 --fallback-y 300 --wallet --headed --keep-open
SKILL_DIR="<path-to-this-skill>"
# Auto-approve the MetaMask connection popup
node $SKILL_DIR/scripts/wallet-connect-helper.js wallet-approve --wallet --headed --keep-open
What this does:
SKILL_DIR="<path-to-this-skill>"
# Take screenshot to verify wallet is connected
node $SKILL_DIR/scripts/wallet-connect-helper.js screenshot after-connect.jpg --wallet --headed --keep-open
Verification Criteria:
If connection fails, retry up to 3 times:
# Attempt 1 failed? Try again
node $SKILL_DIR/scripts/wallet-connect-helper.js wallet-navigate "$DAPP_URL" --wallet --headed --keep-open
# ... repeat steps 2-6
# After 3 failures, STOP and report error
SKILL_DIR="<path-to-this-skill>"
DAPP_URL="http://localhost:3000"
# 1. Navigate to DApp
node $SKILL_DIR/scripts/wallet-connect-helper.js wallet-navigate "$DAPP_URL" --wallet --headed --keep-open
# 2. Click Connect Wallet using text selector (PREFERRED)
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "Connect Wallet" --wallet --headed --keep-open
# Output: { "success": true, "method": "text selector: button:has-text(\"Connect Wallet\")" }
# 3. If wallet modal appears, click MetaMask option
node $SKILL_DIR/scripts/wallet-connect-helper.js wait 1000 --wallet --headed --keep-open
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "MetaMask" --wallet --headed --keep-open
# Output: { "success": true, "method": "text selector: text=\"MetaMask\"" }
# 4. Approve in MetaMask
node $SKILL_DIR/scripts/wallet-connect-helper.js wallet-approve --wallet --headed --keep-open
# 5. Verify connection
node $SKILL_DIR/scripts/wallet-connect-helper.js screenshot connected.jpg --wallet --headed --keep-open
# AI verifies: "Wallet address 0x1234...abcd visible - SUCCESS"
# If dapp-click "Connect Wallet" fails, use fallback coordinates:
node $SKILL_DIR/scripts/wallet-connect-helper.js screenshot find-button.jpg --wallet --headed --keep-open
# AI analyzes screenshot: "Connect button at x=900, y=50"
node $SKILL_DIR/scripts/wallet-connect-helper.js dapp-click "Connect Wallet" --fallback-x 900 --fallback-y 50 --wallet --headed --keep-open
| Command | Description |
|---|---|
dapp-click "<text>" | PREFERRED - Click element by text (e.g., "Connect Wallet", "MetaMask") |
dapp-click --css "<selector>" | Click element by CSS selector |
dapp-click "<text>" --fallback-x X --fallback-y Y | Click with coordinate fallback |
wallet-navigate <url> | Navigate to DApp with wallet extension |
wallet-approve | Auto-approve MetaMask popup |
| Command | Description |
|---|---|
wallet-switch-network <name> | Switch network |
wallet-get-address | Get connected address |
screenshot [name] | Take screenshot for AI analysis |
wait <ms> | Wait milliseconds |
# By text (try multiple labels)
dapp-click "Connect Wallet" --wallet --headed --keep-open
dapp-click "MetaMask" --wallet --headed --keep-open
# By CSS selector
dapp-click --css "button[data-testid='connect']" --wallet --headed --keep-open
dapp-click --css ".connect-button" --wallet --headed --keep-open
# With fallback coordinates (when selectors fail)
dapp-click "Connect" --fallback-x 900 --fallback-y 50 --wallet --headed --keep-open
dapp-click --css "button.connect-btn"wait 2000./test-output/extensions/metamask/ existsweb3.enabled: true in configAfter wallet connection is verified:
wallet-approve--keep-open) for subsequent test steps--wallet --headed flags for wallet operations