ស្វ័យប្រវត្តិកម្មកម្មវិធីរុករក

ក្រុមពាក្យបញ្ជាកម្មវិធីរុករក cmux ផ្ដល់ស្វ័យប្រវត្តិកម្មកម្មវិធីរុករកលើ surface កម្មវិធីរុករក cmux។ ប្រើវាដើម្បីរុករក, ធ្វើអន្តរកម្មជាមួយធាតុ DOM, ពិនិត្យស្ថានភាពទំព័រ, វាយតម្លៃ JavaScript, និងគ្រប់គ្រងទិន្នន័យវគ្គកម្មវិធីរុករក។

សន្ទស្សន៍ពាក្យបញ្ជា

ប្រភេទពាក្យបញ្ជារង
ការរុករកនិងការកំណត់គោលដៅidentify, open, open-split, navigate, back, forward, reload, url, focus-webview, is-webview-focused
ការរង់ចាំwait
អន្តរកម្ម DOMclick, dblclick, hover, focus, check, uncheck, scroll-into-view, type, fill, press, keydown, keyup, select, scroll
ការពិនិត្យsnapshot, screenshot, get, is, find, highlight
JavaScript និងការចាក់បញ្ចូលeval, addinitscript, addscript, addstyle
ស៊ុម, ប្រអប់សន្ទនា, ការទាញយកframe, dialog, download
ស្ថានភាពនិងទិន្នន័យវគ្គcookies, storage, state
ផ្ទាំងនិងកំណត់ត្រាtab, console, errors

ការកំណត់គោលដៅ surface កម្មវិធីរុករក

ពាក្យបញ្ជារងភាគច្រើនត្រូវការ surface គោលដៅ។ អ្នកអាចបញ្ជូនវាតាមទីតាំង ឬជាមួយ --surface។

# Open a new browser split
cmux browser open https://example.com

# Discover focused IDs and browser metadata
cmux browser identify
cmux browser identify --surface surface:2

# Positional vs flag targeting are equivalent
cmux browser surface:2 url
cmux browser --surface surface:2 url

ការរុករក

cmux browser open https://example.com
cmux browser open-split https://news.ycombinator.com

cmux browser surface:2 navigate https://example.org/docs --snapshot-after
cmux browser surface:2 back
cmux browser surface:2 forward
cmux browser surface:2 reload --snapshot-after
cmux browser surface:2 url

cmux browser surface:2 focus-webview
cmux browser surface:2 is-webview-focused

ការរង់ចាំ

ប្រើ wait ដើម្បីរង់ចាំរហូតដល់ selectors, អត្ថបទ, ផ្នែក URL, ស្ថានភាពផ្ទុក, ឬលក្ខខណ្ឌ JavaScript ត្រូវបានបំពេញ។

cmux browser surface:2 wait --load-state complete --timeout-ms 15000
cmux browser surface:2 wait --selector "#checkout" --timeout-ms 10000
cmux browser surface:2 wait --text "Order confirmed"
cmux browser surface:2 wait --url-contains "/dashboard"
cmux browser surface:2 wait --function "window.__appReady === true"

អន្តរកម្ម DOM

សកម្មភាពផ្លាស់ប្ដូរគាំទ្រ --snapshot-after សម្រាប់ការផ្ទៀងផ្ទាត់រហ័សក្នុងស្គ្រីប។

cmux browser surface:2 click "button[type='submit']" --snapshot-after
cmux browser surface:2 dblclick ".item-row"
cmux browser surface:2 hover "#menu"
cmux browser surface:2 focus "#email"
cmux browser surface:2 check "#terms"
cmux browser surface:2 uncheck "#newsletter"
cmux browser surface:2 scroll-into-view "#pricing"

cmux browser surface:2 type "#search" "cmux"
cmux browser surface:2 fill "#email" --text "ops@example.com"
cmux browser surface:2 fill "#email" --text ""
cmux browser surface:2 press Enter
cmux browser surface:2 keydown Shift
cmux browser surface:2 keyup Shift
cmux browser surface:2 select "#region" "us-east"
cmux browser surface:2 scroll --dy 800 --snapshot-after
cmux browser surface:2 scroll --selector "#log-view" --dx 0 --dy 400

ការពិនិត្យ

ប្រើ getters ដែលមានរចនាសម្ព័ន្ធសម្រាប់ស្គ្រីប និង snapshots/screenshots សម្រាប់ការត្រួតពិនិត្យដោយមនុស្ស។

cmux browser surface:2 snapshot --interactive --compact
cmux browser surface:2 snapshot --selector "main" --max-depth 5
cmux browser surface:2 screenshot --out /tmp/cmux-page.png

cmux browser surface:2 get title
cmux browser surface:2 get url
cmux browser surface:2 get text "h1"
cmux browser surface:2 get html "main"
cmux browser surface:2 get value "#email"
cmux browser surface:2 get attr "a.primary" --attr href
cmux browser surface:2 get count ".row"
cmux browser surface:2 get box "#checkout"
cmux browser surface:2 get styles "#total" --property color

cmux browser surface:2 is visible "#checkout"
cmux browser surface:2 is enabled "button[type='submit']"
cmux browser surface:2 is checked "#terms"

cmux browser surface:2 find role button --name "Continue"
cmux browser surface:2 find text "Order confirmed"
cmux browser surface:2 find label "Email"
cmux browser surface:2 find placeholder "Search"
cmux browser surface:2 find alt "Product image"
cmux browser surface:2 find title "Open settings"
cmux browser surface:2 find testid "save-btn"
cmux browser surface:2 find first ".row"
cmux browser surface:2 find last ".row"
cmux browser surface:2 find nth 2 ".row"

cmux browser surface:2 highlight "#checkout"

ការវាយតម្លៃនិងចាក់បញ្ចូល JavaScript

cmux browser surface:2 eval "document.title"
cmux browser surface:2 eval --script "window.location.href"

cmux browser surface:2 addinitscript "window.__cmuxReady = true;"
cmux browser surface:2 addscript "document.querySelector('#name')?.focus()"
cmux browser surface:2 addstyle "#debug-banner { display: none !important; }"

ស្ថានភាព

ពាក្យបញ្ជាទិន្នន័យវគ្គគ្រប ​​cookies, local/session storage, និង snapshots ស្ថានភាពកម្មវិធីរុករកពេញលេញ។

cmux browser surface:2 cookies get
cmux browser surface:2 cookies get --name session_id
cmux browser surface:2 cookies set session_id abc123 --domain example.com --path /
cmux browser surface:2 cookies clear --name session_id
cmux browser surface:2 cookies clear --all

cmux browser surface:2 storage local set theme dark
cmux browser surface:2 storage local get theme
cmux browser surface:2 storage local clear
cmux browser surface:2 storage session set flow onboarding
cmux browser surface:2 storage session get flow

cmux browser surface:2 state save /tmp/cmux-browser-state.json
cmux browser surface:2 state load /tmp/cmux-browser-state.json

ផ្ទាំង

ប្រតិបត្តិការផ្ទាំងកម្មវិធីរុករកផ្គូផ្គងទៅ surface កម្មវិធីរុករកក្នុងក្រុមផ្ទាំងកម្មវិធីរុករកដែលកំពុងដំណើរការ។

cmux browser surface:2 tab list
cmux browser surface:2 tab new https://example.com/pricing

# Switch by index or by target surface
cmux browser surface:2 tab switch 1
cmux browser surface:2 tab switch surface:7

# Close current tab or a specific target
cmux browser surface:2 tab close
cmux browser surface:2 tab close surface:7

Console និងកំហុស

cmux browser surface:2 console list
cmux browser surface:2 console clear

cmux browser surface:2 errors list
cmux browser surface:2 errors clear

ប្រអប់សន្ទនា

cmux browser surface:2 dialog accept
cmux browser surface:2 dialog accept "Confirmed by automation"
cmux browser surface:2 dialog dismiss

ស៊ុម

# Enter an iframe context
cmux browser surface:2 frame "iframe[name='checkout']"
cmux browser surface:2 click "#pay-now"

# Return to the top-level document
cmux browser surface:2 frame main

ការទាញយក

cmux browser surface:2 click "a#download-report"
cmux browser surface:2 download --path /tmp/report.csv --timeout-ms 30000

គំរូទូទៅ

រុករក, រង់ចាំ, ពិនិត្យ

cmux browser open https://example.com/login
cmux browser surface:2 wait --load-state complete --timeout-ms 15000
cmux browser surface:2 snapshot --interactive --compact
cmux browser surface:2 get title

បំពេញទម្រង់និងផ្ទៀងផ្ទាត់អត្ថបទជោគជ័យ

cmux browser surface:2 fill "#email" --text "ops@example.com"
cmux browser surface:2 fill "#password" --text "$PASSWORD"
cmux browser surface:2 click "button[type='submit']" --snapshot-after
cmux browser surface:2 wait --text "Welcome"
cmux browser surface:2 is visible "#dashboard"

ចាប់យកវត្ថុ debug នៅពេលបរាជ័យ

cmux browser surface:2 console list
cmux browser surface:2 errors list
cmux browser surface:2 screenshot --out /tmp/cmux-failure.png
cmux browser surface:2 snapshot --interactive --compact

រក្សាទុកនិងស្ដារវគ្គកម្មវិធីរុករក

cmux browser surface:2 state save /tmp/session.json
# ...later...
cmux browser surface:2 state load /tmp/session.json
cmux browser surface:2 reload