This commit is contained in:
+22
-2
@@ -27,7 +27,9 @@ BrowseWeb({ url: "output/viewer.html" })
|
||||
オプション:
|
||||
- `waitFor`: 待機する CSS セレクタ(省略時は load イベント完了まで待機)
|
||||
- `extractSelector`: 特定要素のテキストだけ抽出する CSS セレクタ
|
||||
- `screenshot`: スクリーンショットを保存するファイル名(例: `"page.png"` → `output/page.png`)
|
||||
- `screenshot`: スクリーンショットを保存するファイル名(例: `"page.png"` → `output/page.png`)。縦長ページは既定で分割保存(下記)
|
||||
- `screenshotSegments`: `false` で分割せずフルページ 1 枚(既定: 分割あり)
|
||||
- `screenshotMaxSegments`: 分割の最大枚数(既定 10)
|
||||
- `timeout`: タイムアウト(ms、デフォルト 60000)
|
||||
|
||||
### 2. アクションモード — 連続操作
|
||||
@@ -47,11 +49,29 @@ BrowseWeb({
|
||||
- `goto` — `url` で指定したページに遷移
|
||||
- `click` — `selector` または `ref` で要素をクリック
|
||||
- `fill` — `selector` または `ref` の input/textarea に `value` を入力
|
||||
- `screenshot` — `value` で指定したファイル名で保存(省略時 `screenshot.png`)
|
||||
- `screenshot` — `value` で指定したファイル名で保存(省略時 `screenshot.png`)。縦長ページは既定で分割保存(下記)。`segments: false` でフルページ 1 枚、`maxSegments` で枚数上限を調整
|
||||
- `getText` — 全ページのスナップショット(ref 注釈付き)または `selector` 内のテキストを取得
|
||||
- `wait` — `ms` ミリ秒待機(最大 30000)
|
||||
- `dumpHtml` — `ref` または `selector`(省略時 body)の outerHTML を取得(脱出口、後述)
|
||||
|
||||
### スクリーンショットの分割保存
|
||||
|
||||
縦長ページを 1 枚で撮ると画像が極端に縦長になり、細部が潰れて読み取りづらくなる。BrowseWeb は既定で、ページを **1 画面ぶん(ビューポート高さ)ごとに区切って複数枚**に分割保存する。
|
||||
|
||||
- 1 画面に収まるページはそのまま `output/page.png` の 1 枚(連番なし)
|
||||
- 2 画面ぶん以上あるページは `output/page-001.png`, `output/page-002.png` … と連番で保存し、戻り値に全ファイルを列挙する
|
||||
- 無限スクロールなどの暴走を防ぐため、既定で最大 10 枚まで(`screenshotMaxSegments` / アクションの `maxSegments` で変更)。上限で打ち切った場合は戻り値にその旨を表示する
|
||||
- 分割せずフルページ 1 枚が欲しいときは `screenshotSegments: false`(基本モード)またはアクションの `segments: false`
|
||||
|
||||
```js
|
||||
// 縦長レポートを 1 画面ぶんずつ分割して撮る(既定)
|
||||
BrowseWeb({ url: "output/report.html", screenshot: "report.png" })
|
||||
// → output/report-001.png, output/report-002.png, ...
|
||||
|
||||
// フルページ 1 枚で撮りたいとき
|
||||
BrowseWeb({ url: "output/report.html", screenshot: "report.png", screenshotSegments: false })
|
||||
```
|
||||
|
||||
## 長文ページの取得(preview + ファイル保存)
|
||||
|
||||
`getText` (selector 有無問わず) およびスナップショットの戻り値が **5000 文字を超える** 場合、フルテキストはワークスペースの `logs/browse/{ISO-timestamp}-{hash}.txt` に保存され、戻り値は **先頭 5000 文字 + 続きの取得方法案内** になる:
|
||||
|
||||
Reference in New Issue
Block a user