Documentation
¶
Index ¶
- func RunDaemon(opts Options) error
- type AuthProfile
- type AuthVault
- type Client
- func (c *Client) Back() error
- func (c *Client) Check(id int) error
- func (c *Client) ClearGeo() error
- func (c *Client) Click(id int) error
- func (c *Client) ClickNewTab(id int) error
- func (c *Client) ClipboardCopy() error
- func (c *Client) ClipboardPaste() error
- func (c *Client) ClipboardRead() (string, error)
- func (c *Client) ClipboardWrite(text string) error
- func (c *Client) Close() error
- func (c *Client) Confirm(id string) error
- func (c *Client) ConsoleClear() error
- func (c *Client) ConsoleMessages(level string) ([]browser.ConsoleMessage, error)
- func (c *Client) ConsoleStart() error
- func (c *Client) CookieDelete(name string) error
- func (c *Client) CookieSet(cookie browser.CookieInfo) error
- func (c *Client) CookiesClear() error
- func (c *Client) CookiesGet() ([]browser.CookieInfo, error)
- func (c *Client) DblClick(id int) error
- func (c *Client) Deny(id string) error
- func (c *Client) DiffScreenshot(baselineFile, outputFile string, threshold float64, fullPage bool) (Response, error)
- func (c *Client) DiffSnapshot(baselineFile string, snapOpts browser.SnapshotOptions) (Response, error)
- func (c *Client) DiffURL(url1, url2 string, includeScreenshot, fullPage bool, threshold float64, ...) (Response, error)
- func (c *Client) Download(id int, saveDir string) (string, error)
- func (c *Client) Drag(srcID, dstID int) error
- func (c *Client) Eval(expression string) (string, error)
- func (c *Client) ExportState(path string) error
- func (c *Client) Fill(id int, text string) error
- func (c *Client) FindAlt(text string, exact bool) (string, error)
- func (c *Client) FindLabel(label string) (string, error)
- func (c *Client) FindLabelExact(label string, exact bool) (string, error)
- func (c *Client) FindLast(cssSelector string) (string, error)
- func (c *Client) FindNth(cssSelector string, n int) (string, error)
- func (c *Client) FindPlaceholder(text string, exact bool) (string, error)
- func (c *Client) FindRole(role, name string) (string, error)
- func (c *Client) FindRoleExact(role, name string, exact bool) (string, error)
- func (c *Client) FindTestID(testID string) (string, error)
- func (c *Client) FindText(text string) (string, error)
- func (c *Client) FindTextExact(text string, exact bool) (string, error)
- func (c *Client) FindTitle(text string, exact bool) (string, error)
- func (c *Client) Focus(id int) error
- func (c *Client) Forward() error
- func (c *Client) GetAttr(id int, name string) (string, error)
- func (c *Client) GetBox(id int) (*browser.BoxResult, error)
- func (c *Client) GetCDPURL() (string, error)
- func (c *Client) GetCount(cssSelector string) (int, error)
- func (c *Client) GetHTML(id int) (string, error)
- func (c *Client) GetStyles(id int) (string, error)
- func (c *Client) GetText(id int) (string, error)
- func (c *Client) GetTitle() (string, error)
- func (c *Client) GetURL() (string, error)
- func (c *Client) GetValue(id int) (string, error)
- func (c *Client) Highlight(id int) error
- func (c *Client) Hover(id int) error
- func (c *Client) ImportState(path string) error
- func (c *Client) IsChecked(id int) (bool, error)
- func (c *Client) IsEnabled(id int) (bool, error)
- func (c *Client) IsVisible(id int) (bool, error)
- func (c *Client) KeyboardInsertText(text string) error
- func (c *Client) KeyboardType(text string) error
- func (c *Client) MouseClick(x, y float64, button string) error
- func (c *Client) MouseDown(x, y float64, button string) error
- func (c *Client) MouseMove(x, y float64) error
- func (c *Client) MouseUp(x, y float64, button string) error
- func (c *Client) MouseWheel(x, y, deltaX, deltaY float64) error
- func (c *Client) NetworkClearRequests() error
- func (c *Client) NetworkRequests() ([]browser.NetworkRequest, error)
- func (c *Client) NetworkRoute(pattern, action string) error
- func (c *Client) NetworkStartLogging() error
- func (c *Client) NetworkUnroute(pattern string) error
- func (c *Client) Open(url string) error
- func (c *Client) OpenDevTools() error
- func (c *Client) PDF(path string, args PDFArgs) error
- func (c *Client) PageErrors() ([]browser.PageError, error)
- func (c *Client) PageErrorsClear() error
- func (c *Client) Press(key string) error
- func (c *Client) ProfilerStart() error
- func (c *Client) ProfilerStop(outputFile string) error
- func (c *Client) RecordStart(outputPath string) error
- func (c *Client) RecordStop() (int, error)
- func (c *Client) Reload() error
- func (c *Client) Screenshot(path string, args ScreenshotArgs) error
- func (c *Client) ScreenshotAnnotated(path string, args ScreenshotArgs) error
- func (c *Client) Scroll(direction string, amount int) error
- func (c *Client) ScrollIntoView(id int) error
- func (c *Client) Select(id int, values ...string) error
- func (c *Client) SessionInfo() (string, error)
- func (c *Client) SetColorScheme(scheme string) error
- func (c *Client) SetCredentials(user, pass string) error
- func (c *Client) SetDevice(name string) error
- func (c *Client) SetGeo(lat, lon float64) error
- func (c *Client) SetHeaders(headers map[string]string) error
- func (c *Client) SetMedia(features []browser.MediaFeature) error
- func (c *Client) SetOffline(offline bool) error
- func (c *Client) SetViewport(width, height int) error
- func (c *Client) SetViewportWithScale(width, height int, scale float64) error
- func (c *Client) Snapshot(opts browser.SnapshotOptions) (Response, error)
- func (c *Client) StorageClear(storageType string) error
- func (c *Client) StorageDelete(storageType, key string) error
- func (c *Client) StorageGet(storageType, key string) (string, error)
- func (c *Client) StorageGetAll(storageType string) (map[string]string, error)
- func (c *Client) StorageSet(storageType, key, value string) error
- func (c *Client) TabClose(index int) error
- func (c *Client) TabList() ([]browser.TabInfo, error)
- func (c *Client) TabNew(url string) error
- func (c *Client) TabSwitch(index int) error
- func (c *Client) TraceStart(categories string) error
- func (c *Client) TraceStop(outputFile string) error
- func (c *Client) Type(id int, text string) error
- func (c *Client) Uncheck(id int) error
- func (c *Client) Upload(id int, files ...string) error
- func (c *Client) Wait(d time.Duration) error
- func (c *Client) WaitDownload(saveDir string) (string, error)
- func (c *Client) WaitFunc(expression string) error
- func (c *Client) WaitHidden(cssSelector string) error
- func (c *Client) WaitLoad() error
- func (c *Client) WaitSelector(cssSelector string) error
- func (c *Client) WaitText(text string) error
- func (c *Client) WaitURL(pattern string) error
- type ConfirmStore
- type Options
- type PDFArgs
- type PendingAction
- type Request
- type Response
- type ScreenshotArgs
- type SessionEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthProfile ¶
type AuthProfile struct {
Name string `json:"name"`
URL string `json:"url"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
UsernameSelector string `json:"usernameSelector,omitempty"`
PasswordSelector string `json:"passwordSelector,omitempty"`
SubmitSelector string `json:"submitSelector,omitempty"`
}
AuthProfile represents a saved authentication profile.
type AuthVault ¶
type AuthVault struct {
// contains filtered or unexported fields
}
AuthVault manages a local credential store.
func NewAuthVault ¶
NewAuthVault creates or loads the auth vault from ~/.ko-browser/auth.json.
func (*AuthVault) Get ¶
func (v *AuthVault) Get(name string) (AuthProfile, bool)
Get returns a profile by name.
func (*AuthVault) List ¶
func (v *AuthVault) List() []AuthProfile
List returns all profile names sorted.
func (*AuthVault) Save ¶
func (v *AuthVault) Save(p AuthProfile) error
Save stores a profile in the vault.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ClickNewTab ¶
func (*Client) ClipboardCopy ¶
func (*Client) ClipboardPaste ¶
func (*Client) ClipboardRead ¶
func (*Client) ClipboardWrite ¶
func (*Client) ConsoleClear ¶
func (*Client) ConsoleMessages ¶
func (c *Client) ConsoleMessages(level string) ([]browser.ConsoleMessage, error)
func (*Client) ConsoleStart ¶
func (*Client) CookieDelete ¶
func (*Client) CookiesClear ¶
func (*Client) CookiesGet ¶
func (c *Client) CookiesGet() ([]browser.CookieInfo, error)
func (*Client) DiffScreenshot ¶
func (*Client) DiffSnapshot ¶
func (*Client) ExportState ¶
func (*Client) FindLabelExact ¶
func (*Client) FindPlaceholder ¶
func (*Client) FindRoleExact ¶
func (*Client) FindTextExact ¶
func (*Client) ImportState ¶
func (*Client) KeyboardInsertText ¶
func (*Client) KeyboardType ¶
func (*Client) MouseWheel ¶
func (*Client) NetworkClearRequests ¶
func (*Client) NetworkRequests ¶
func (c *Client) NetworkRequests() ([]browser.NetworkRequest, error)
func (*Client) NetworkRoute ¶
func (*Client) NetworkStartLogging ¶
func (*Client) NetworkUnroute ¶
func (*Client) OpenDevTools ¶
func (*Client) PageErrorsClear ¶
func (*Client) ProfilerStart ¶
func (*Client) ProfilerStop ¶
func (*Client) RecordStart ¶
func (*Client) RecordStop ¶
func (*Client) Screenshot ¶
func (c *Client) Screenshot(path string, args ScreenshotArgs) error
func (*Client) ScreenshotAnnotated ¶
func (c *Client) ScreenshotAnnotated(path string, args ScreenshotArgs) error
func (*Client) ScrollIntoView ¶
func (*Client) SessionInfo ¶
func (*Client) SetColorScheme ¶
func (*Client) SetCredentials ¶
func (*Client) SetOffline ¶
func (*Client) SetViewport ¶
func (*Client) SetViewportWithScale ¶
func (*Client) StorageClear ¶
func (*Client) StorageDelete ¶
func (*Client) StorageGetAll ¶
func (*Client) StorageSet ¶
func (*Client) TraceStart ¶
func (*Client) WaitHidden ¶
func (*Client) WaitSelector ¶
type ConfirmStore ¶
type ConfirmStore struct {
// contains filtered or unexported fields
}
ConfirmStore manages pending actions that require confirmation.
func NewConfirmStore ¶
func NewConfirmStore(categories []string, timeout time.Duration) *ConfirmStore
NewConfirmStore creates a new confirmation store. categories is a set of action names that require confirmation.
func (*ConfirmStore) Add ¶
func (cs *ConfirmStore) Add(command, argsDesc string) *PendingAction
Add registers a pending action and returns its ID.
func (*ConfirmStore) Confirm ¶
func (cs *ConfirmStore) Confirm(id string) error
Confirm approves a pending action.
func (*ConfirmStore) Deny ¶
func (cs *ConfirmStore) Deny(id string) error
Deny rejects a pending action.
func (*ConfirmStore) NeedsConfirmation ¶
func (cs *ConfirmStore) NeedsConfirmation(command string) bool
NeedsConfirmation checks if a command category requires confirmation.
type Options ¶
type Options struct {
Name string
Headed bool
Timeout time.Duration
Debug bool
Profile string
StatePath string
// Phase 8.3: Global options
UserAgent string
Proxy string
ProxyBypass string
IgnoreHTTPSErrors bool
AllowFileAccess bool
Extensions []string
ExtraArgs []string
DownloadPath string
ScreenshotDir string
ScreenshotFormat string
// Phase 8.4: Confirmation
ConfirmActions []string
}
type PDFArgs ¶
type PDFArgs struct {
Landscape bool `json:"landscape,omitempty"`
PrintBG bool `json:"printBG,omitempty"`
}
PDFArgs holds arguments for the pdf command.
type PendingAction ¶
type PendingAction struct {
ID string `json:"id"`
Command string `json:"command"`
Args string `json:"args"`
CreatedAt time.Time `json:"createdAt"`
// contains filtered or unexported fields
}
PendingAction represents an action awaiting confirmation.
func (*PendingAction) Wait ¶
func (pa *PendingAction) Wait() bool
Wait blocks until the pending action is confirmed or denied. Returns true if confirmed, false if denied or timed out.
type Request ¶
type Request struct {
Command string `json:"command"`
URL string `json:"url,omitempty"`
ID int `json:"id,omitempty"`
Text string `json:"text,omitempty"`
Key string `json:"key,omitempty"`
Values []string `json:"values,omitempty"`
Direction string `json:"direction,omitempty"`
Amount int `json:"amount,omitempty"`
AttrName string `json:"attrName,omitempty"`
CSSSelector string `json:"cssSelector,omitempty"`
Expression string `json:"expression,omitempty"`
WaitDuration time.Duration `json:"waitDuration,omitempty"`
SnapshotOptions browser.SnapshotOptions `json:"snapshotOptions,omitempty"`
// Phase 3: Screenshot/PDF/Eval/Find
FilePath string `json:"filePath,omitempty"`
ScreenshotArgs ScreenshotArgs `json:"screenshotArgs,omitempty"`
PDFArgs PDFArgs `json:"pdfArgs,omitempty"`
Role string `json:"role,omitempty"`
N int `json:"n,omitempty"`
// Phase 4: Drag/Upload/Download/Mouse
DstID int `json:"dstId,omitempty"`
Files []string `json:"files,omitempty"`
SaveDir string `json:"saveDir,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
DeltaX float64 `json:"deltaX,omitempty"`
DeltaY float64 `json:"deltaY,omitempty"`
MouseBtn string `json:"mouseBtn,omitempty"`
// Phase 5: Tab/Network/Storage
TabIndex int `json:"tabIndex,omitempty"`
Pattern string `json:"pattern,omitempty"`
RouteAction string `json:"routeAction,omitempty"`
Cookie browser.CookieInfo `json:"cookie,omitempty"`
StorageType string `json:"storageType,omitempty"`
StorageKey string `json:"storageKey,omitempty"`
StorageVal string `json:"storageVal,omitempty"`
// Phase 6: Settings/Debug/Clipboard
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
DeviceName string `json:"deviceName,omitempty"`
Lat float64 `json:"lat,omitempty"`
Lon float64 `json:"lon,omitempty"`
Offline *bool `json:"offline,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
User string `json:"user,omitempty"`
Pass string `json:"pass,omitempty"`
MediaFeatures []browser.MediaFeature `json:"mediaFeatures,omitempty"`
ColorScheme string `json:"colorScheme,omitempty"`
ClipboardText string `json:"clipboardText,omitempty"`
ConsoleLevel string `json:"consoleLevel,omitempty"`
// Phase 7: Advanced features
Target string `json:"target,omitempty"` // connect target (port or ws URL)
BaselineFile string `json:"baselineFile,omitempty"` // diff baseline file path
OutputFile string `json:"outputFile,omitempty"` // output file path for diff/trace/profiler/record
Threshold float64 `json:"threshold,omitempty"` // screenshot diff threshold
URL2 string `json:"url2,omitempty"` // second URL for diff url
IncludeScreenshot bool `json:"includeScreenshot,omitempty"` // diff url: also compare screenshots
Categories string `json:"categories,omitempty"` // trace categories
StatePath string `json:"statePath,omitempty"` // state import/export path
// Phase 8: Missing commands/flags
NewTab bool `json:"newTab,omitempty"` // click with new tab
Exact bool `json:"exact,omitempty"` // exact matching for find
Scale float64 `json:"scale,omitempty"` // viewport scale factor
Cursor bool `json:"cursor,omitempty"` // show cursor in snapshot
ConfirmID string `json:"confirmId,omitempty"` // confirmation ID for confirm/deny
}
type Response ¶
type Response struct {
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
Text string `json:"text,omitempty"`
RawCount int `json:"rawCount,omitempty"`
ElementCount int `json:"elementCount,omitempty"`
IntResult int `json:"intResult,omitempty"`
BoolResult *bool `json:"boolResult,omitempty"`
Box *browser.BoxResult `json:"box,omitempty"`
FilePath string `json:"filePath,omitempty"`
// Phase 5
Tabs []browser.TabInfo `json:"tabs,omitempty"`
Cookies []browser.CookieInfo `json:"cookies,omitempty"`
Requests []browser.NetworkRequest `json:"requests,omitempty"`
StorageItems map[string]string `json:"storageItems,omitempty"`
// Phase 6
ConsoleMessages []browser.ConsoleMessage `json:"consoleMessages,omitempty"`
PageErrors []browser.PageError `json:"pageErrors,omitempty"`
// Phase 7
DiffResult *browser.DiffSnapshotResult `json:"diffResult,omitempty"`
ScreenshotDiff *browser.DiffScreenshotResult `json:"screenshotDiff,omitempty"`
DiffURLResult *browser.DiffURLResult `json:"diffURLResult,omitempty"`
// Phase 8.4: Confirmation
ConfirmationRequired bool `json:"confirmationRequired,omitempty"`
ConfirmID string `json:"confirmId,omitempty"`
}
type ScreenshotArgs ¶
type ScreenshotArgs struct {
FullPage bool `json:"fullPage,omitempty"`
Quality int `json:"quality,omitempty"`
ElementID int `json:"elementID,omitempty"`
Annotate bool `json:"annotate,omitempty"`
}
ScreenshotArgs holds arguments for the screenshot command.
type SessionEntry ¶
SessionEntry represents an active session found on the system.
func ListSessions ¶
func ListSessions() ([]SessionEntry, error)
ListSessions scans the temp directory for active ko-browser session sockets.