Skip to content

Browser Automation

Full web automation: navigation, interaction, data extraction, screenshots, and performance monitoring.

38 modules

ModuleDescription
點擊元素點擊頁面上的元素
關閉瀏覽器關閉瀏覽器實例並釋放資源
擷取主控台擷取瀏覽器主控台日誌(錯誤、警告、資訊)
管理 Cookie取得、設定或清除瀏覽器 Cookie
處理對話框處理 alert、confirm 和 prompt 對話框
下載檔案從瀏覽器下載檔案
拖放拖放元素
模擬裝置模擬裝置或設定自訂視窗大小
確保瀏覽器確保存在瀏覽器工作階段(重用或啟動)
執行 JavaScript在頁面上下文中執行 JavaScript 程式碼
擷取資料從頁面擷取結構化資料
尋找元素在頁面中尋找元素並回傳元素 ID 列表
填寫表單智慧填表,自動偵測欄位
切換框架切換到 iframe 或框架上下文
模擬地理位置模擬瀏覽器地理位置
前往網址開啟指定的網址
懸停元素將滑鼠懸停在元素上
啟動瀏覽器使用 Playwright 啟動新的瀏覽器實例
導航歷史瀏覽器歷史記錄導航(返回、前進、重新載入)
網路監控監控和攔截網路請求
列出頁面列出所有開啟的瀏覽器頁面/分頁
翻頁與擷取自動翻頁並擷取資料
產生 PDF從目前頁面產生 PDF
效能指標收集瀏覽器效能指標
按鍵按下鍵盤按鍵
錄製操作錄製使用者操作為工作流程
釋放瀏覽器釋放瀏覽器會話(僅在擁有時關閉)
截圖擷取目前頁面的截圖
捲動頁面捲動頁面到元素、位置或方向
選擇選項從下拉選單選擇選項
DOM 快照擷取當前頁面的 DOM 快照
瀏覽器儲存空間存取 localStorage 和 sessionStorage
管理分頁建立、切換和關閉瀏覽器分頁
瀏覽器追蹤開始、停止或儲存瀏覽器效能追蹤
輸入文字在輸入欄位中輸入文字
上傳檔案上傳檔案到檔案輸入元素
設定視窗取得或設定瀏覽器視窗大小
等待等待一段時間或直到元素出現

Modules

點擊元素

browser.click

點擊頁面上的元素

Parameters:

NameTypeRequiredDefaultDescription
click_methodselect (text, button, id, selector)NotextChoose the easiest way to identify the element you want to click
targetstringNo-e.g. "Submit", "Next Page", "Login"
selectorstringNo-CSS selector, XPath, or text selector
buttonselect (left, right, middle)NoleftWhich mouse button to use for clicking
click_countnumberNo1Number of clicks (2 for double-click, 3 for triple-click)
forcebooleanNoFalseForce click even if element is not actionable (covered, invisible)
modifiersarrayNo-Modifier keys to hold during click
timeoutnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
browserobjectBrowser session (pass-through for chaining)
statusstring操作狀態(成功/錯誤)
selectorstring被點擊的選擇器
methodstringClick method used

Example: Example

yaml
click_method: text
target: Submit

Example: Example

yaml
click_method: id
target: login-button

Example: Example

yaml
click_method: selector
selector: #submit-button

關閉瀏覽器

browser.close

關閉瀏覽器實例並釋放資源

Parameters:

NameTypeRequiredDefaultDescription
_no_paramsbooleanNoTrueThis module requires no parameters

Output:

FieldTypeDescription
statusstring操作狀態
messagestring關閉結果訊息

Example: Example

yaml

擷取主控台

browser.console

擷取瀏覽器主控台日誌(錯誤、警告、資訊)

Parameters:

NameTypeRequiredDefaultDescription
levelselect (all, error, warning, info, log)NoallFilter console messages by level
timeoutnumberNo5000Maximum time to wait in milliseconds
clear_existingbooleanNoFalseClear existing messages before capturing

Output:

FieldTypeDescription
statusstring操作狀態
messagesarray主控台訊息列表
countnumber日誌數量

Example: Example

yaml
timeout: 3000

Example: Example

yaml
level: error
timeout: 5000

browser.cookies

取得、設定或清除瀏覽器 Cookie

Parameters:

NameTypeRequiredDefaultDescription
actionselect (get, set, clear, delete)Yes-Action to perform on the storage
namestringNo-Name of the cookie
valuestringNo-Value of the cookie
domainstringNo-Cookie domain
pathstringNo/Cookie path
securebooleanNoFalseWhether cookie is secure (HTTPS only)
httpOnlybooleanNoFalseWhether cookie is HTTP only
expiresnumberNo-Cookie expiration time (Unix timestamp)

Output:

FieldTypeDescription
statusstring操作狀態
cookiesarrayCookie 列表
countnumberCookie 數量

Example: Example

yaml
action: get

Example: Example

yaml
action: get
name: session_id

Example: Example

yaml
action: set
name: user_pref
value: dark_mode
domain: example.com

Example: Example

yaml
action: clear

處理對話框

browser.dialog

處理 alert、confirm 和 prompt 對話框

Parameters:

NameTypeRequiredDefaultDescription
actionselect (accept, dismiss, listen)Yes-How to respond to the dialog
prompt_textstringNo-Text to enter in prompt dialog (for accept action)
timeoutnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
messagestring對話框訊息
typestring對話框類型
default_valuestring對話框預設值

Example: Example

yaml
action: accept

Example: Example

yaml
action: dismiss

Example: Example

yaml
action: accept
prompt_text: Hello World

Example: Example

yaml
action: listen
timeout: 5000

下載檔案

browser.download

從瀏覽器下載檔案

Parameters:

NameTypeRequiredDefaultDescription
selectorstringNo-CSS selector, XPath, or text selector to find the element
save_pathstringYes-Path where to save the downloaded file
timeout_msnumberNo60000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
pathstring檔案路徑
filenamestring檔案名稱
sizenumber檔案大小

Example: Example

yaml
selector: #download-btn
save_path: /downloads/report.pdf

Example: Example

yaml
selector: a.download
save_path: /downloads/large-file.zip
timeout_ms: 120000

拖放

browser.drag

拖放元素

Parameters:

NameTypeRequiredDefaultDescription
sourcestringYes-CSS selector, XPath, or text selector to find the element
targetstringYes-CSS selector, XPath, or text selector to find the element
source_positionobjectNo-Position within source element {x, y} as percentages
target_positionobjectNo-Position within target element {x, y} as percentages
timeoutnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
sourcestring來源元素位置
targetstring目標元素位置

Example: Example

yaml
source: #item1
target: #dropzone

Example: Example

yaml
source: .draggable
target: .container
target_position: {"x": 0.5, "y": 0.5}

模擬裝置

browser.emulate

模擬裝置或設定自訂視窗大小

Parameters:

NameTypeRequiredDefaultDescription
deviceselect (iphone_12, iphone_14, iphone_14_pro_max, iphone_se, pixel_7, pixel_5, galaxy_s21, galaxy_s23, ipad_pro, ipad_mini, galaxy_tab_s8, desktop_chrome, desktop_firefox, desktop_safari, desktop_edge, laptop, macbook_pro, custom)Yes-要模擬的裝置名稱(例如 iPhone 13)
widthnumberNo-視窗寬度(像素)
heightnumberNo-視窗高度(像素)
user_agentstringNo-自訂使用者代理字串
is_mobilebooleanNo-是否模擬行動裝置
has_touchbooleanNo-裝置是否支援觸控
device_scale_factornumberNo-裝置像素比

Output:

FieldTypeDescription
statusstring操作狀態(成功/錯誤)
devicestring模擬的裝置名稱
viewportobject目前的視窗尺寸
is_mobileboolean是否啟用行動裝置模擬

Example: Example

yaml
device: iphone_14

Example: Example

yaml
device: ipad_pro

Example: Example

yaml
device: custom
width: 400
height: 800
is_mobile: true
has_touch: true
device_scale_factor: 2

Example: Example

yaml
device: desktop_chrome
user_agent: CustomBot/1.0

確保瀏覽器

browser.ensure

確保存在瀏覽器工作階段(重用或啟動)

Parameters:

NameTypeRequiredDefaultDescription
headlessbooleanNoFalseRun browser without visible window
widthnumberNo1280Browser viewport width in pixels
heightnumberNo720Browser viewport height in pixels

Output:

FieldTypeDescription
statusstring瀏覽器是被啟動還是重用
messagestring瀏覽器是被啟動還是重用
is_ownerboolean瀏覽器是被啟動還是重用

Example: Example

yaml
headless: false

Example: Example

yaml
headless: true

執行 JavaScript

browser.evaluate

在頁面上下文中執行 JavaScript 程式碼

Parameters:

NameTypeRequiredDefaultDescription
scriptstringYes-JavaScript code to execute (can use return statement)
argsarrayNo-Arguments to pass to the script function

Output:

FieldTypeDescription
statusstring操作狀態
resultany執行結果

Example: Example

yaml
script: return document.title

Example: Example

yaml
script: return document.querySelectorAll("a").length

Example: Example

yaml
script: (selector) => document.querySelector(selector)?.textContent
args: ["#header"]

Example: Example

yaml
script: document.body.style.backgroundColor = "red"; return "done"

擷取資料

browser.extract

從頁面擷取結構化資料

Parameters:

NameTypeRequiredDefaultDescription
selectorstringYes-CSS selector, XPath, or text selector to find the element
limitnumberNo-Maximum number of items to extract
fieldsobjectNo-Define fields to extract from each item

Output:

FieldTypeDescription
statusstring操作狀態
dataarray擷取的資料
countnumber擷取的項目數量

Example: Example

yaml
selector: .g
limit: 10
fields: {"title": {"selector": "h3", "type": "text"}, "url": {"selector": "a", "type": "attribute", "attribute": "href"}}

尋找元素

browser.find

在頁面中尋找元素並回傳元素 ID 列表

Parameters:

NameTypeRequiredDefaultDescription
selectorstringYes-CSS selector, XPath, or text selector to find the element
limitnumberNo-Maximum number of items to extract

Output:

FieldTypeDescription
statusstring操作狀態
countnumber找到的元素數量
element_idsarray元素 ID 列表

Example: Find search results

yaml
selector: div.tF2Cxc
limit: 10

填寫表單

browser.form

智慧填表,自動偵測欄位

Parameters:

NameTypeRequiredDefaultDescription
form_selectorstringNo-CSS selector for the form element (optional)
dataobjectYes-Key-value pairs to fill (key = field name/id, value = content)
field_mappingobjectNo-Custom selector mapping
clear_before_fillbooleanNoTrueClear existing field values before filling
submitbooleanNoFalseSubmit form after filling
submit_selectorstringNo-CSS selector for submit button
delay_between_fields_msnumberNo100Delay between filling each field (for more human-like behavior)

Output:

FieldTypeDescription
filled_fieldsarray每個欄位填寫的延遲時間(模擬人類行為)
failed_fieldsarray已填寫欄位的清單
submittedboolean已填寫欄位的清單

Example: Example

yaml
data: {"email": "user@example.com", "password": "secret123"}
submit: true

Example: Example

yaml
data: {"username": "john_doe", "bio": "Hello world"}
field_mapping: {"username": "#user-name-input", "bio": "textarea.bio-field"}

切換框架

browser.frame

切換到 iframe 或框架上下文

Parameters:

NameTypeRequiredDefaultDescription
selectorstringNo-CSS selector, XPath, or text selector to find the element
namestringNo-Name attribute of the frame (alternative to selector)
urlstringNo-URL pattern to match frame (alternative to selector)
actionstringNoenterFrame action to perform
timeoutnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
frame_urlstring框架 URL
frame_namestring框架名稱
framesarray框架列表

Example: Example

yaml
selector: iframe#content-frame

Example: Example

yaml
name: main-content

Example: Example

yaml
action: exit

Example: Example

yaml
action: list

模擬地理位置

browser.geolocation

模擬瀏覽器地理位置

Parameters:

NameTypeRequiredDefaultDescription
latitudenumberYes-Latitude coordinate (-90 to 90)
longitudenumberYes-Longitude coordinate (-180 to 180)
accuracynumberNo100Position accuracy in meters

Output:

FieldTypeDescription
statusstring操作狀態
locationobject位置資訊

Example: Example

yaml
latitude: 37.7749
longitude: -122.4194

Example: Example

yaml
latitude: 51.5074
longitude: -0.1278
accuracy: 10

Example: Example

yaml
latitude: 35.6762
longitude: 139.6503

前往網址

browser.goto

開啟指定的網址

Parameters:

NameTypeRequiredDefaultDescription
urlstringYes-URL to navigate to
wait_untilselect (load, domcontentloaded, networkidle)NodomcontentloadedWhen to consider navigation complete
timeout_msnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
urlstring實際開啟的網址

Example: Example

yaml
url: https://www.google.com
wait_until: domcontentloaded

懸停元素

browser.hover

將滑鼠懸停在元素上

Parameters:

NameTypeRequiredDefaultDescription
selectorstringYes-CSS selector, XPath, or text selector to find the element
timeout_msnumberNo30000Maximum time to wait in milliseconds
positionobjectNo-Click position relative to element (0-1 range)

Output:

FieldTypeDescription
statusstring操作狀態
selectorstring懸停的選擇器

Example: Example

yaml
selector: .menu-item

Example: Example

yaml
selector: #dropdown-trigger
timeout_ms: 5000

啟動瀏覽器

browser.launch

使用 Playwright 啟動新的瀏覽器實例

Parameters:

NameTypeRequiredDefaultDescription
headlessbooleanNoFalseRun browser without visible window
widthnumberNo1280Browser viewport width in pixels
heightnumberNo720Browser viewport height in pixels
browser_typeselect (chromium, firefox, webkit)Nochromium要使用的瀏覽器引擎(chromium、firefox、webkit)
proxystringNo-代理伺服器 URL
user_agentstringNo-自訂使用者代理字串
localestringNoen-USBrowser locale (e.g. en-US, zh-TW, ja-JP)
slow_monumberNo0以指定毫秒數放慢操作
record_video_dirstringNo-Directory to save recorded videos (enables Playwright video recording)

Output:

FieldTypeDescription
statusstring操作狀態
messagestring啟動結果訊息
browser_typestring啟動的瀏覽器類型
headlessboolean瀏覽器是否以無頭模式運行
viewportobject目前的視窗尺寸

Example: Example

yaml
headless: true

Example: Example

yaml
headless: false

導航歷史

browser.navigation

瀏覽器歷史記錄導航(返回、前進、重新載入)

Parameters:

NameTypeRequiredDefaultDescription
actionselect (back, forward, reload)YesreloadWhich navigation action to perform
wait_untilselect (load, domcontentloaded, networkidle)NodomcontentloadedWhen to consider navigation complete
timeout_msnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態(成功/錯誤)
actionstring執行的導航動作
urlstring導航後的當前 URL

Example: Example

yaml
action: back

Example: Example

yaml
action: forward

Example: Example

yaml
action: reload
wait_until: networkidle

網路監控

browser.network

監控和攔截網路請求

Parameters:

NameTypeRequiredDefaultDescription
actionselect (monitor, block, intercept)Yes-Network action to perform
url_patternstringNo-Regex pattern to match request URLs
resource_typestringNo-Filter by resource type (document, script, image, etc)
timeoutnumberNo30000Maximum time to wait in milliseconds
mock_responseobjectNo-Response to return for intercepted requests

Output:

FieldTypeDescription
statusstring操作狀態
requestsarray請求列表
blocked_countnumber被阻擋的請求數量

Example: Example

yaml
action: monitor
url_pattern: .*api.*
timeout: 10000

Example: Example

yaml
action: block
resource_type: image

Example: Example

yaml
action: intercept
url_pattern: .*users.*
mock_response: {"status": 200, "body": "{\"users\": []}"}

列出頁面

browser.pages

列出所有開啟的瀏覽器頁面/分頁

Parameters:

NameTypeRequiredDefaultDescription
include_detailsbooleanNoTrue包含每個頁面的詳細資訊
include_content_infobooleanNoFalse包含每個頁面的內容類型資訊

Output:

FieldTypeDescription
statusstring操作狀態(成功/錯誤)
pagesarray開啟頁面的清單
countnumber開啟頁面的數量
current_indexnumber目前使用中頁面的索引

Example: Example

yaml
include_details: true

Example: Example

yaml
include_details: false

Example: Example

yaml
include_details: true
include_content_info: true

翻頁與擷取

browser.pagination

自動翻頁並擷取資料

Parameters:

NameTypeRequiredDefaultDescription
modeselect (next_button, infinite_scroll, page_numbers, load_more)Nonext_buttonHow to navigate between pages
item_selectorstringYes-CSS selector for items to extract on each page
fieldsobjectNo-Field definitions {name: {selector, attribute?}}
next_selectorstringNo-CSS selector for next page button
load_more_selectorstringNo-CSS selector for load more button
max_pagesnumberNo10Maximum number of pages to process (0 = unlimited)
max_itemsnumberNo0Stop after collecting this many items (0 = unlimited)
wait_between_pages_msnumberNo1000Wait time between page navigations
wait_for_selectorstringNo-Wait for this element after page change
scroll_amountnumberNo1000Pixels to scroll for infinite scroll mode
no_more_indicatorstringNo-Selector that appears when no more pages (stops pagination)

Output:

FieldTypeDescription
itemsarray當沒有更多頁面時出現的選擇器(停止翻頁)
total_itemsinteger所有頁面中擷取的所有項目
pages_processedinteger所有頁面中擷取的所有項目
stopped_reasonstring處理的頁數

Example: Example

yaml
mode: next_button
item_selector: .product-card
fields: {"title": {"selector": ".title"}, "price": {"selector": ".price"}, "link": {"selector": "a", "attribute": "href"}}
next_selector: .pagination .next
max_pages: 5

Example: Example

yaml
mode: infinite_scroll
item_selector: .feed-item
fields: {"content": {"selector": ".content"}, "author": {"selector": ".author"}}
max_items: 100
no_more_indicator: .end-of-feed

Example: Example

yaml
mode: load_more
item_selector: .list-item
load_more_selector: button.load-more
max_pages: 10

產生 PDF

browser.pdf

從目前頁面產生 PDF

Parameters:

NameTypeRequiredDefaultDescription
pathstringNo-Path where the output file will be saved
page_sizeselect (A4, Letter, Legal, A3, A5)NoA4Page size format
orientationselect (portrait, landscape)NoportraitPage orientation
print_backgroundbooleanNoTrueInclude background graphics
scalenumberNo1Scale of the webpage rendering (0.1-2)
marginnumberNo20Page margin in millimeters
headerstringNo-Header text for each page
footerstringNo-Footer text for each page

Output:

FieldTypeDescription
statusstring操作狀態
pathstringPDF 檔案路徑
sizenumberPDF 檔案大小

Example: Example

yaml
path: /output/page.pdf

Example: Example

yaml
path: /output/landscape.pdf
landscape: true

Example: Example

yaml
path: /output/custom.pdf
margin: {"top": "1cm", "bottom": "1cm", "left": "2cm", "right": "2cm"}

效能指標

browser.performance

收集瀏覽器效能指標

Parameters:

NameTypeRequiredDefaultDescription
metricsarrayNo['all']要收集的效能指標
timeout_msnumberNo3000超時時間(毫秒)
setup_observersbooleanNoTrue在收集前設置效能觀察者

Output:

FieldTypeDescription
statusstring操作狀態(成功/錯誤)
metricsobject收集到的效能指標

Example: Example

yaml
metrics: ["all"]
timeout_ms: 5000

Example: Example

yaml
metrics: ["lcp", "fcp", "cls"]

Example: Example

yaml
metrics: ["ttfb", "domContentLoaded", "load"]
timeout_ms: 0

按鍵

browser.press

按下鍵盤按鍵

Parameters:

NameTypeRequiredDefaultDescription
keystringYes-The key to press (e.g., Enter, Escape, Tab)

Output:

FieldTypeDescription
statusstring操作狀態
keystring按下的按鍵

Example: Example

yaml
key: Enter

Example: Example

yaml
key: Escape

錄製操作

browser.record

錄製使用者操作為工作流程

Parameters:

NameTypeRequiredDefaultDescription
actionstringYes-Recording action to perform
output_formatstringNoyamlFormat for recorded workflow
output_pathstringNo-Path where the output file will be saved

Output:

FieldTypeDescription
statusstring操作狀態
recordingarray錄製狀態
workflowstring錄製的工作流程

Example: Example

yaml
action: start

Example: Example

yaml
action: stop
output_format: yaml

Example: Example

yaml
action: get

釋放瀏覽器

browser.release

釋放瀏覽器會話(僅在擁有時關閉)

Parameters:

NameTypeRequiredDefaultDescription
forcebooleanNoFalse即使此範本不擁有也關閉瀏覽器

Output:

FieldTypeDescription
statusstring即使此範本不擁有也關閉瀏覽器
messagestring執行的操作
was_ownerboolean執行的操作

Example: Example

yaml

Example: Example

yaml
force: true

截圖

browser.screenshot

擷取目前頁面的截圖

Parameters:

NameTypeRequiredDefaultDescription
pathstringNoscreenshot.pngPath where the output file will be saved
full_pagebooleanNoFalseCapture the entire scrollable page
formatselect (png, jpeg, webp)NopngImage format for the screenshot
qualitynumberNo-Quality for JPEG/WebP format (0-100)

Output:

FieldTypeDescription
statusstring操作狀態
filepathstring截圖檔案路徑

Example: Example

yaml
path: output/page.png

捲動頁面

browser.scroll

捲動頁面到元素、位置或方向

Parameters:

NameTypeRequiredDefaultDescription
selectorstringNo-CSS selector, XPath, or text selector to find the element
directionselect (down, up, left, right)NodownDirection to scroll the page
amountnumberNo500Pixels to scroll (ignored if selector is provided)
behaviorselect (smooth, instant)NosmoothHow the scroll animation behaves

Output:

FieldTypeDescription
statusstring操作狀態
scrolled_toobject捲動到的位置

Example: Example

yaml
selector: #footer

Example: Example

yaml
direction: down
amount: 500

Example: Example

yaml
direction: up
amount: 10000
behavior: smooth

選擇選項

browser.select

從下拉選單選擇選項

Parameters:

NameTypeRequiredDefaultDescription
selectorstringYes-CSS selector, XPath, or text selector to find the element
valuestringNo-Option value attribute to select
labelstringNo-Option text content to select (alternative to value)
indexnumberNo-Option index to select (0-based)
timeoutnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
selectedarray選擇的值
selectorstring選擇器

Example: Example

yaml
selector: select#country
value: us

Example: Example

yaml
selector: select#country
label: United States

Example: Example

yaml
selector: select#country
index: 2

DOM 快照

browser.snapshot

擷取當前頁面的 DOM 快照

Parameters:

NameTypeRequiredDefaultDescription
formatselect (html, mhtml, text)Nohtml輸出格式(html 或 text)
selectorstringNo-擷取特定元素的 CSS 選擇器
pathstringNo-儲存快照的路徑

Output:

FieldTypeDescription
statusstring操作狀態(成功/錯誤)
formatstring快照的格式
contentstring快照內容
pathstring快照儲存的路徑
size_bytesnumber快照的大小(位元組)

Example: Example

yaml
format: html

Example: Example

yaml
format: mhtml
path: /tmp/page.mhtml

Example: Example

yaml
format: text
selector: article.main-content

Example: Example

yaml
format: html
selector: #main
path: /tmp/section.html

瀏覽器儲存空間

browser.storage

存取 localStorage 和 sessionStorage

Parameters:

NameTypeRequiredDefaultDescription
actionselect (get, set, remove, clear, keys, length)Yes-Action to perform on the storage
typeselect (local, session)NolocalBrowser storage type to access
keystringNo-Storage key
valuestringNo-Value to store

Output:

FieldTypeDescription
statusstring操作狀態
valueany取得的值
keysarray儲存的鍵列表
lengthnumber儲存項目數量

Example: Example

yaml
action: get
type: local
key: user_token

Example: Example

yaml
action: set
type: session
key: temp_data
value: {"id": 123}

Example: Example

yaml
action: clear
type: local

Example: Example

yaml
action: keys
type: local

管理分頁

browser.tab

建立、切換和關閉瀏覽器分頁

Parameters:

NameTypeRequiredDefaultDescription
actionstringYes-Tab action to perform
urlstringNo-URL to navigate to
indexnumberNo-Tab index to switch to or close (0-based)

Output:

FieldTypeDescription
statusstring操作狀態
tab_countnumber分頁總數
current_indexnumber目前分頁索引
tabsarray分頁列表

Example: Example

yaml
action: new
url: https://example.com

Example: Example

yaml
action: switch
index: 0

Example: Example

yaml
action: close

Example: Example

yaml
action: list

瀏覽器追蹤

browser.trace

開始、停止或儲存瀏覽器效能追蹤

Parameters:

NameTypeRequiredDefaultDescription
actionstringYes-追蹤動作(開始、停止、儲存)
categoriesarrayNo['devtools.timeline']要擷取的追蹤類別
screenshotsbooleanNoTrue在追蹤中包含螢幕截圖
pathstringNo-儲存追蹤檔案的路徑

Output:

FieldTypeDescription
statusstring操作狀態(成功/錯誤)
tracingboolean追蹤是否目前正在進行
pathstring追蹤儲存的路徑
size_bytesnumber追蹤檔案的大小(位元組)

Example: Example

yaml
action: start
screenshots: true

Example: Example

yaml
action: start
categories: ["devtools.timeline", "v8.execute"]
screenshots: false

Example: Example

yaml
action: stop
path: /tmp/performance-trace.json

輸入文字

browser.type

在輸入欄位中輸入文字

Parameters:

NameTypeRequiredDefaultDescription
type_methodselect (placeholder, label, name, id, selector)NoplaceholderChoose the easiest way to identify the input field
targetstringNo-e.g. "Enter your email", "Email", "username"
selectorstringNo-CSS selector, XPath, or text selector
input_typeselect (text, password, email)NotextType of input field — use Password to mask the value in the builder
textstringYes-
sensitive_textstringYes-
delaynumberNo0Delay between keystrokes in milliseconds
clearbooleanNoFalseClear the input field before typing
timeoutnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
browserobjectBrowser session (pass-through for chaining)
statusstring操作狀態
selectorstring輸入的選擇器
methodstringType method used

Example: Example

yaml
type_method: placeholder
target: Enter your email
text: user@example.com

Example: Example

yaml
type_method: label
target: Email
text: user@example.com

Example: Example

yaml
type_method: placeholder
target: Password
input_type: password
sensitive_text: ${env.LOGIN_PASSWORD}

Example: Example

yaml
type_method: selector
selector: #email
text: user@example.com

上傳檔案

browser.upload

上傳檔案到檔案輸入元素

Parameters:

NameTypeRequiredDefaultDescription
selectorstringYes-CSS selector, XPath, or text selector to find the element
file_pathstringYes-Local path to the file to upload
timeout_msnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
filenamestring檔案名稱
sizenumber檔案大小
selectorstring選擇器

Example: Example

yaml
selector: input[type="file"]
file_path: /path/to/image.png

Example: Example

yaml
selector: #file-upload
file_path: /path/to/document.pdf

設定視窗

browser.viewport

取得或設定瀏覽器視窗大小

Parameters:

NameTypeRequiredDefaultDescription
widthnumberYes1280視窗寬度(像素)
heightnumberYes720視窗高度(像素)

Output:

FieldTypeDescription
statusstring操作狀態(成功/錯誤)
viewportobject目前的視窗尺寸
previous_viewportobject先前的視窗尺寸

Example: Example

yaml
width: 375
height: 667

Example: Example

yaml
width: 768
height: 1024

Example: Example

yaml
width: 1920
height: 1080

Example: Example

yaml
width: 1366
height: 768

等待

browser.wait

等待一段時間或直到元素出現

Parameters:

NameTypeRequiredDefaultDescription
duration_msnumberNo1000Duration of the operation in milliseconds
selectorstringNo-CSS selector, XPath, or text selector to find the element
stateselect (visible, hidden, attached, detached)Novisible等待的狀態(可見、隱藏、附加、分離)
timeout_msnumberNo30000Maximum time to wait in milliseconds

Output:

FieldTypeDescription
statusstring操作狀態
selectorstring等待的選擇器
duration_msnumber等待時間(毫秒)

Example: Example

yaml
duration_ms: 2000

Example: Example

yaml
selector: #loading-complete
timeout_ms: 5000

Released under the Apache 2.0 License.