|
| 1 | +--- |
| 2 | +name: playwright-cli |
| 3 | +description: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages. |
| 4 | +allowed-tools: Bash(playwright-cli:*) |
| 5 | +--- |
| 6 | + |
| 7 | +# Browser Automation with playwright-cli |
| 8 | + |
| 9 | +## Quick start |
| 10 | + |
| 11 | +```bash |
| 12 | +playwright-cli open https://playwright.dev |
| 13 | +playwright-cli click e15 |
| 14 | +playwright-cli type "page.click" |
| 15 | +playwright-cli press Enter |
| 16 | +``` |
| 17 | + |
| 18 | +## Core workflow |
| 19 | + |
| 20 | +1. Navigate: `playwright-cli open https://example.com` |
| 21 | +2. Interact using refs from the snapshot |
| 22 | +3. Re-snapshot after significant changes |
| 23 | + |
| 24 | +## Commands |
| 25 | + |
| 26 | +### Core |
| 27 | + |
| 28 | +```bash |
| 29 | +playwright-cli open https://example.com/ |
| 30 | +playwright-cli close |
| 31 | +playwright-cli type "search query" |
| 32 | +playwright-cli click e3 |
| 33 | +playwright-cli dblclick e7 |
| 34 | +playwright-cli fill e5 "user@example.com" |
| 35 | +playwright-cli drag e2 e8 |
| 36 | +playwright-cli hover e4 |
| 37 | +playwright-cli select e9 "option-value" |
| 38 | +playwright-cli upload ./document.pdf |
| 39 | +playwright-cli check e12 |
| 40 | +playwright-cli uncheck e12 |
| 41 | +playwright-cli snapshot |
| 42 | +playwright-cli eval "document.title" |
| 43 | +playwright-cli eval "el => el.textContent" e5 |
| 44 | +playwright-cli dialog-accept |
| 45 | +playwright-cli dialog-accept "confirmation text" |
| 46 | +playwright-cli dialog-dismiss |
| 47 | +playwright-cli resize 1920 1080 |
| 48 | +``` |
| 49 | +
|
| 50 | +### Navigation |
| 51 | +
|
| 52 | +```bash |
| 53 | +playwright-cli go-back |
| 54 | +playwright-cli go-forward |
| 55 | +playwright-cli reload |
| 56 | +``` |
| 57 | +
|
| 58 | +### Keyboard |
| 59 | +
|
| 60 | +```bash |
| 61 | +playwright-cli press Enter |
| 62 | +playwright-cli press ArrowDown |
| 63 | +playwright-cli keydown Shift |
| 64 | +playwright-cli keyup Shift |
| 65 | +``` |
| 66 | +
|
| 67 | +### Mouse |
| 68 | +
|
| 69 | +```bash |
| 70 | +playwright-cli mousemove 150 300 |
| 71 | +playwright-cli mousedown |
| 72 | +playwright-cli mousedown right |
| 73 | +playwright-cli mouseup |
| 74 | +playwright-cli mouseup right |
| 75 | +playwright-cli mousewheel 0 100 |
| 76 | +``` |
| 77 | +
|
| 78 | +### Save as |
| 79 | +
|
| 80 | +```bash |
| 81 | +playwright-cli screenshot |
| 82 | +playwright-cli screenshot e5 |
| 83 | +playwright-cli pdf |
| 84 | +``` |
| 85 | +
|
| 86 | +### Tabs |
| 87 | +
|
| 88 | +```bash |
| 89 | +playwright-cli tab-list |
| 90 | +playwright-cli tab-new |
| 91 | +playwright-cli tab-new https://example.com/page |
| 92 | +playwright-cli tab-close |
| 93 | +playwright-cli tab-close 2 |
| 94 | +playwright-cli tab-select 0 |
| 95 | +``` |
| 96 | +
|
| 97 | +### DevTools |
| 98 | +
|
| 99 | +```bash |
| 100 | +playwright-cli console |
| 101 | +playwright-cli console warning |
| 102 | +playwright-cli network |
| 103 | +playwright-cli run-code "await page.waitForTimeout(1000)" |
| 104 | +playwright-cli tracing-start |
| 105 | +playwright-cli tracing-stop |
| 106 | +``` |
| 107 | +
|
| 108 | +### Sessions |
| 109 | +
|
| 110 | +```bash |
| 111 | +playwright-cli --session=mysession open example.com |
| 112 | +playwright-cli --session=mysession click e6 |
| 113 | +playwright-cli session-list |
| 114 | +playwright-cli session-stop mysession |
| 115 | +playwright-cli session-stop-all |
| 116 | +playwright-cli session-delete |
| 117 | +playwright-cli session-delete mysession |
| 118 | +``` |
| 119 | +
|
| 120 | +## Example: Form submission |
| 121 | +
|
| 122 | +```bash |
| 123 | +playwright-cli open https://example.com/form |
| 124 | +playwright-cli snapshot |
| 125 | + |
| 126 | +playwright-cli fill e1 "user@example.com" |
| 127 | +playwright-cli fill e2 "password123" |
| 128 | +playwright-cli click e3 |
| 129 | +playwright-cli snapshot |
| 130 | +``` |
| 131 | +
|
| 132 | +## Example: Multi-tab workflow |
| 133 | +
|
| 134 | +```bash |
| 135 | +playwright-cli open https://example.com |
| 136 | +playwright-cli tab-new https://example.com/other |
| 137 | +playwright-cli tab-list |
| 138 | +playwright-cli tab-select 0 |
| 139 | +playwright-cli snapshot |
| 140 | +``` |
| 141 | +
|
| 142 | +## Example: Debugging with DevTools |
| 143 | +
|
| 144 | +```bash |
| 145 | +playwright-cli open https://example.com |
| 146 | +playwright-cli click e4 |
| 147 | +playwright-cli fill e7 "test" |
| 148 | +playwright-cli console |
| 149 | +playwright-cli network |
| 150 | +``` |
| 151 | +
|
| 152 | +```bash |
| 153 | +playwright-cli open https://example.com |
| 154 | +playwright-cli tracing-start |
| 155 | +playwright-cli click e4 |
| 156 | +playwright-cli fill e7 "test" |
| 157 | +playwright-cli tracing-stop |
| 158 | +``` |
0 commit comments