enbu 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,401 @@
1
+ # enbu
2
+
3
+ > In martial arts, Enbu (演武) is a choreographed demonstration where practitioners perform predefined sequences of techniques. Similarly, Enbu lets you define test sequences in YAML and performs them in the browser — a rehearsal before production.
4
+
5
+ Webブラウザ向けのシンプルなE2Eテストフレームワーク。YAMLベースのフロー定義で、[agent-browser](https://github.com/vercel-labs/agent-browser)のパワフルなブラウザ自動化を活用できます。
6
+
7
+ ## 特徴
8
+
9
+ - **YAMLベースのフロー定義** - 人間が読みやすいシンプルな形式でテストを記述
10
+ - **セマンティックな要素指定** - テキスト、ARIAロール、ラベル等で要素を特定
11
+ - **自動待機** - 要素が現れるまで自動的に待機(明示的なsleep不要)
12
+ - **agent-browser統合** - Rust製の高速ブラウザ自動化エンジンを利用
13
+
14
+ ## 前提条件
15
+
16
+ agent-browserがインストールされている必要があります。
17
+
18
+ ```bash
19
+ # agent-browserのインストール(事前に必要)
20
+ npm install -g agent-browser
21
+ ```
22
+
23
+ ## インストール
24
+
25
+ ```bash
26
+ npm install -g enbu
27
+ # または
28
+ npx enbu
29
+ ```
30
+
31
+ ## クイックスタート
32
+
33
+ ### 1. プロジェクトの初期化
34
+
35
+ ```bash
36
+ npx enbu init
37
+ ```
38
+
39
+ これにより `.abflow/` ディレクトリとサンプルフローが作成されます。
40
+
41
+ ### 2. フローの作成
42
+
43
+ `.abflow/login.enbu.yaml`:
44
+
45
+ ```yaml
46
+ # ログインフローのテスト
47
+ steps:
48
+ - open: https://example.com/login
49
+ - click: "ログイン"
50
+ - type:
51
+ selector: "メールアドレス"
52
+ text: "user@example.com"
53
+ - type:
54
+ selector: "パスワード"
55
+ text: "password123"
56
+ - click: "送信"
57
+ - assertVisible: "ダッシュボード"
58
+ ```
59
+
60
+ ### 3. テストの実行
61
+
62
+ ```bash
63
+ # 全フローを実行
64
+ npx enbu
65
+
66
+ # 特定のフローを実行
67
+ npx enbu .abflow/login.enbu.yaml
68
+ ```
69
+
70
+ ## agent-browser コマンド対応表
71
+
72
+ 本ツールは [agent-browser](https://github.com/vercel-labs/agent-browser) のコマンドをYAMLから利用できます。以下は対応状況です。
73
+
74
+ ### Core Commands
75
+
76
+ | agent-browser | 対応 | YAML記法 |
77
+ |---------------|:----:|----------|
78
+ | `open <url>` | ✅ | `- open: <url>` |
79
+ | `click <selector>` | ✅ | `- click: <selector>` |
80
+ | `dblclick <selector>` | ❌ | - |
81
+ | `focus <selector>` | ❌ | - |
82
+ | `type <selector> <text>` | ✅ | `- type: { selector: <selector>, value: <text> }` |
83
+ | `fill <selector> <text>` | ✅ | `- fill: { selector: <selector>, value: <text> }` |
84
+ | `press <key>` | ✅ | `- press: <key>` |
85
+ | `keydown <key>` | ❌ | - |
86
+ | `keyup <key>` | ❌ | - |
87
+ | `hover <selector>` | ✅ | `- hover: <selector>` |
88
+ | `select <selector> <value>` | ✅ | `- select: { selector: <selector>, value: <value> }` |
89
+ | `check <selector>` | ❌ | - |
90
+ | `uncheck <selector>` | ❌ | - |
91
+ | `scroll <direction> [px]` | ✅ | `- scroll: { direction: up\|down\|left\|right, amount: <px> }` |
92
+ | `scrollintoview <selector>` | ✅ | `- scrollIntoView: <selector>` |
93
+ | `drag <source> <target>` | ❌ | - |
94
+ | `upload <selector> <files>` | ❌ | - |
95
+ | `screenshot [path]` | ✅ | `- screenshot: <path>` |
96
+ | `pdf <path>` | ❌ | - |
97
+ | `snapshot` | ✅ | `- snapshot` |
98
+ | `eval <js>` | ✅ | `- eval: <script>` |
99
+ | `close` | ❌ | - |
100
+
101
+ ### Get Info
102
+
103
+ | agent-browser | 対応 | YAML記法 |
104
+ |---------------|:----:|----------|
105
+ | `get text <selector>` | ❌ | - |
106
+ | `get html <selector>` | ❌ | - |
107
+ | `get value <selector>` | ❌ | - |
108
+ | `get attr <selector> <attr>` | ❌ | - |
109
+ | `get title` | ❌ | - |
110
+ | `get url` | ❌ | - |
111
+ | `get count <selector>` | ❌ | - |
112
+ | `get box <selector>` | ❌ | - |
113
+
114
+ ### Check State
115
+
116
+ | agent-browser | 対応 | YAML記法 |
117
+ |---------------|:----:|----------|
118
+ | `is visible <selector>` | ✅ | `- assertVisible: <selector>` |
119
+ | `is enabled <selector>` | ✅ | `- assertEnabled: <selector>` |
120
+ | `is checked <selector>` | ✅ | `- assertChecked: <selector>` |
121
+
122
+ ### Find Elements
123
+
124
+ | agent-browser | 対応 | YAML記法 |
125
+ |---------------|:----:|----------|
126
+ | `find role <role> <action> [value]` | ✅ | セレクタ文字列として利用可能 |
127
+ | `find text <text> <action>` | ✅ | セレクタ文字列として利用可能 |
128
+ | `find label <label> <action> [value]` | ✅ | セレクタ文字列として利用可能 |
129
+ | `find placeholder <placeholder> <action> [value]` | ✅ | セレクタ文字列として利用可能 |
130
+ | `find alt <text> <action>` | ✅ | セレクタ文字列として利用可能 |
131
+ | `find title <text> <action>` | ✅ | セレクタ文字列として利用可能 |
132
+ | `find testid <id> <action> [value]` | ✅ | セレクタ文字列として利用可能 |
133
+ | `find first <selector> <action> [value]` | ❌ | - |
134
+ | `find last <selector> <action> [value]` | ❌ | - |
135
+ | `find nth <n> <selector> <action> [value]` | ❌ | - |
136
+
137
+ ### Wait
138
+
139
+ | agent-browser | 対応 | YAML記法 |
140
+ |---------------|:----:|----------|
141
+ | `wait <selector>` | ✅ | `- wait: "<selector>"` |
142
+ | `wait <ms>` | ✅ | `- wait: <ms>` |
143
+ | `wait --text <text>` | ✅ | `- wait: { text: "<text>" }` |
144
+ | `wait --url <pattern>` | ✅ | `- wait: { url: "<pattern>" }` |
145
+ | `wait --load <state>` | ✅ | `- wait: { load: "<state>" }` |
146
+ | `wait --fn <condition>` | ✅ | `- wait: { fn: "<condition>" }` |
147
+
148
+ ### Mouse Control
149
+
150
+ | agent-browser | 対応 | YAML記法 |
151
+ |---------------|:----:|----------|
152
+ | `mouse move <x> <y>` | ❌ | - |
153
+ | `mouse down [button]` | ❌ | - |
154
+ | `mouse up [button]` | ❌ | - |
155
+ | `mouse wheel <dy> [dx]` | ❌ | - |
156
+
157
+ ### Browser Settings
158
+
159
+ | agent-browser | 対応 | YAML記法 |
160
+ |---------------|:----:|----------|
161
+ | `set viewport <width> <height>` | ❌ | - |
162
+ | `set device <name>` | ❌ | - |
163
+ | `set geo <lat> <lng>` | ❌ | - |
164
+ | `set offline [on\|off]` | ❌ | - |
165
+ | `set headers <json>` | ❌ | - |
166
+ | `set credentials <user> <pass>` | ❌ | - |
167
+ | `set media [dark\|light]` | ❌ | - |
168
+
169
+ ### Cookies & Storage
170
+
171
+ | agent-browser | 対応 | YAML記法 |
172
+ |---------------|:----:|----------|
173
+ | `cookies` | ❌ | - |
174
+ | `cookies set <name> <value>` | ❌ | - |
175
+ | `cookies clear` | ❌ | - |
176
+ | `storage local` | ❌ | - |
177
+ | `storage local <key>` | ❌ | - |
178
+ | `storage local set <key> <value>` | ❌ | - |
179
+ | `storage local clear` | ❌ | - |
180
+ | `storage session` | ❌ | - |
181
+ | `storage session <key>` | ❌ | - |
182
+ | `storage session set <key> <value>` | ❌ | - |
183
+ | `storage session clear` | ❌ | - |
184
+
185
+ ### Network
186
+
187
+ | agent-browser | 対応 | YAML記法 |
188
+ |---------------|:----:|----------|
189
+ | `network route <url>` | ❌ | - |
190
+ | `network route <url> --abort` | ❌ | - |
191
+ | `network route <url> --body <json>` | ❌ | - |
192
+ | `network unroute [url]` | ❌ | - |
193
+ | `network requests` | ❌ | - |
194
+ | `network requests --filter <pattern>` | ❌ | - |
195
+
196
+ ### Tabs & Windows
197
+
198
+ | agent-browser | 対応 | YAML記法 |
199
+ |---------------|:----:|----------|
200
+ | `tab` | ❌ | - |
201
+ | `tab new [url]` | ❌ | - |
202
+ | `tab <n>` | ❌ | - |
203
+ | `tab close [n]` | ❌ | - |
204
+ | `window new` | ❌ | - |
205
+
206
+ ### Frames
207
+
208
+ | agent-browser | 対応 | YAML記法 |
209
+ |---------------|:----:|----------|
210
+ | `frame <selector>` | ❌ | - |
211
+ | `frame main` | ❌ | - |
212
+
213
+ ### Dialogs
214
+
215
+ | agent-browser | 対応 | YAML記法 |
216
+ |---------------|:----:|----------|
217
+ | `dialog accept [text]` | ❌ | - |
218
+ | `dialog dismiss` | ❌ | - |
219
+
220
+ ### Debug
221
+
222
+ | agent-browser | 対応 | YAML記法 |
223
+ |---------------|:----:|----------|
224
+ | `trace start [path]` | ❌ | - |
225
+ | `trace stop [path]` | ❌ | - |
226
+ | `console` | ❌ | - |
227
+ | `console --clear` | ❌ | - |
228
+ | `errors` | ❌ | - |
229
+ | `errors --clear` | ❌ | - |
230
+ | `highlight <selector>` | ❌ | - |
231
+ | `state save <path>` | ❌ | - |
232
+ | `state load <path>` | ❌ | - |
233
+
234
+ ### Navigation
235
+
236
+ | agent-browser | 対応 | YAML記法 |
237
+ |---------------|:----:|----------|
238
+ | `back` | ❌ | - |
239
+ | `forward` | ❌ | - |
240
+ | `reload` | ❌ | - |
241
+
242
+ ### enbu 独自コマンド
243
+
244
+ | コマンド | YAML記法 |
245
+ |----------|----------|
246
+ | assertNotVisible | `- assertNotVisible: <selector>` |
247
+
248
+ ## コマンドリファレンス
249
+
250
+ ### ページを開く
251
+
252
+ ```yaml
253
+ steps:
254
+ - open: https://example.com
255
+ ```
256
+
257
+ ### クリック
258
+
259
+ ```yaml
260
+ steps:
261
+ # セマンティックセレクタ(テキスト、ラベル、ARIAロール等)
262
+ - click: "ログイン"
263
+
264
+ # CSSセレクタ
265
+ - click:
266
+ selector: "#submit-button"
267
+ ```
268
+
269
+ ### テキスト入力
270
+
271
+ ```yaml
272
+ steps:
273
+ - type:
274
+ selector: "ユーザー名"
275
+ text: "山田太郎"
276
+ ```
277
+
278
+ ### アサーション
279
+
280
+ ```yaml
281
+ steps:
282
+ # 要素が表示されていることを確認
283
+ - assertVisible: "ログイン成功"
284
+
285
+ # 要素が表示されていないことを確認
286
+ - assertNotVisible: "エラー"
287
+ ```
288
+
289
+ ### スクリーンショット
290
+
291
+ ```yaml
292
+ steps:
293
+ - screenshot: ./screenshots/result.png
294
+ ```
295
+
296
+ ### スナップショット(デバッグ用)
297
+
298
+ ```yaml
299
+ steps:
300
+ - snapshot
301
+ ```
302
+
303
+ 現在のページのアクセシビリティツリーを取得します。デバッグ時に要素の確認に使用します。
304
+
305
+ ### JavaScript実行
306
+
307
+ ```yaml
308
+ steps:
309
+ - eval: "document.title"
310
+
311
+ # 複数行
312
+ - eval: |
313
+ const element = document.querySelector('#result');
314
+ return element.textContent;
315
+ ```
316
+
317
+ ## 環境変数
318
+
319
+ フロー内で環境変数を使用できます:
320
+
321
+ ```yaml
322
+ steps:
323
+ - type:
324
+ selector: "パスワード"
325
+ text: ${PASSWORD}
326
+ ```
327
+
328
+ ### 環境変数の指定方法
329
+
330
+ #### CLI引数で指定
331
+
332
+ ```bash
333
+ npx enbu --env PASSWORD=secret123
334
+ ```
335
+
336
+ #### YAML内で定義
337
+
338
+ `.abflow/login.enbu.yaml`:
339
+ ```yaml
340
+ env:
341
+ BASE_URL: https://staging.example.com
342
+ steps:
343
+ - open: ${BASE_URL}/login
344
+ ```
345
+
346
+ ## CLI オプション
347
+
348
+ ```bash
349
+ npx enbu [options] [flow-files...]
350
+
351
+ オプション:
352
+ --headed ブラウザを表示して実行(デフォルト: ヘッドレス)
353
+ --env KEY=VALUE 環境変数を設定
354
+ --timeout <ms> デフォルトタイムアウト(デフォルト: 30000)
355
+ --screenshot 失敗時にスクリーンショットを保存
356
+ -v, --verbose 詳細なログを出力
357
+ -h, --help ヘルプを表示
358
+ --version バージョンを表示
359
+ ```
360
+
361
+ ## ディレクトリ構成
362
+
363
+ ```
364
+ your-project/
365
+ ├── .abflow/
366
+ │ ├── login.enbu.yaml
367
+ │ ├── checkout.enbu.yaml
368
+ │ └── shared/
369
+ │ └── auth.enbu.yaml
370
+ └── package.json
371
+ ```
372
+
373
+ ## CI/CD統合
374
+
375
+ ### GitHub Actions
376
+
377
+ ```yaml
378
+ name: E2E Tests
379
+
380
+ on: [push, pull_request]
381
+
382
+ jobs:
383
+ test:
384
+ runs-on: ubuntu-latest
385
+ steps:
386
+ - uses: actions/checkout@v4
387
+
388
+ - name: Setup Node.js
389
+ uses: actions/setup-node@v4
390
+ with:
391
+ node-version: '20'
392
+
393
+ - name: Run E2E tests
394
+ run: npx enbu
395
+ env:
396
+ PASSWORD: ${{ secrets.TEST_PASSWORD }}
397
+ ```
398
+
399
+ ## ライセンス
400
+
401
+ MIT