Documentation
¶
Index ¶
- func ActivateTab(debugURL string, targetID string) error
- func ClickChromeElement(debugURL string, targetURL string, selector string, waitForNavigation bool) error
- func CloseTab(debugURL string, targetID string) error
- func CloseTerminalWindow(cmd *exec.Cmd) error
- func GetChromeDebugURL(profileDir string) (string, error)
- func GetSPKIFingerprint(certPath string) (string, error)
- func GoBack(debugURL string, targetID string) error
- func GoForward(debugURL string, targetID string) error
- func LaunchBrowser(browserType string, proxyAddress string, customCertPath string, ...) (*exec.Cmd, error)
- func OpenChromeTab(debugURL string, url string) (string, error)
- func ReloadTab(debugURL string, targetID string, bypassCache bool) error
- func TakeChromeScreenshot(debugURL string, targetID string, fullPage bool) ([]byte, error)
- type ChromeRemote
- func (cr *ChromeRemote) ActivateTab(targetID string) error
- func (cr *ChromeRemote) ClickElement(targetID string, targetURL string, selector string, waitForNavigation bool) error
- func (cr *ChromeRemote) Close()
- func (cr *ChromeRemote) CloseTab(targetID string) error
- func (cr *ChromeRemote) CloseTargetContext(targetID string)
- func (cr *ChromeRemote) DebugURL() string
- func (cr *ChromeRemote) Evaluate(targetID string, jsExpr string, dest interface{}, timeoutMs int) error
- func (cr *ChromeRemote) GetElements(targetID string, targetURL string) ([]ElementInfo, error)
- func (cr *ChromeRemote) GoBack(targetID string) error
- func (cr *ChromeRemote) GoForward(targetID string) error
- func (cr *ChromeRemote) ListTabs() ([]TabInfo, error)
- func (cr *ChromeRemote) Navigate(targetID string, url string, waitUntil string, timeoutMs int) (*NavigationResult, error)
- func (cr *ChromeRemote) OpenTab(url string) (string, error)
- func (cr *ChromeRemote) ReloadTab(targetID string, bypassCache bool) error
- func (cr *ChromeRemote) TakeScreenshot(targetID string, fullPage bool) ([]byte, error)
- type ElementInfo
- type NavigationResult
- type TabInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActivateTab ¶
func ClickChromeElement ¶
func CloseTerminalWindow ¶
CloseTerminalWindow attempts to close terminal windows for a given process Note: This is a best-effort attempt. macOS terminals launched via AppleScript may not always close cleanly as they detach from the parent process.
func GetChromeDebugURL ¶
GetChromeDebugURL reads the DevTools WebSocket URL from Chrome's profile directory Chrome writes this information to DevToolsActivePort file when launched with --remote-debugging-port
func GetSPKIFingerprint ¶
GetSPKIFingerprint calculates the SHA-256 SPKI fingerprint of a certificate This is used by Chrome to ignore certificate errors for our CA
func LaunchBrowser ¶
Types ¶
type ChromeRemote ¶
type ChromeRemote struct {
// contains filtered or unexported fields
}
ChromeRemote manages a connection to a Chrome instance via DevTools Protocol
func NewChromeRemote ¶
func NewChromeRemote(debugURL string) (*ChromeRemote, error)
NewChromeRemote creates a new ChromeRemote instance connected to the given debug URL
func (*ChromeRemote) ActivateTab ¶
func (cr *ChromeRemote) ActivateTab(targetID string) error
ActivateTab switches focus to a specific tab
func (*ChromeRemote) ClickElement ¶
func (cr *ChromeRemote) ClickElement(targetID string, targetURL string, selector string, waitForNavigation bool) error
ClickElement clicks an element on the page using Chrome DevTools Protocol. targetID can be empty to pick the best tab.
func (*ChromeRemote) Close ¶
func (cr *ChromeRemote) Close()
Close closes the connection to Chrome and all sub-contexts
func (*ChromeRemote) CloseTab ¶
func (cr *ChromeRemote) CloseTab(targetID string) error
CloseTab closes a specific tab
func (*ChromeRemote) CloseTargetContext ¶
func (cr *ChromeRemote) CloseTargetContext(targetID string)
CloseTargetContext manually closes and removes a context from the cache
func (*ChromeRemote) DebugURL ¶
func (cr *ChromeRemote) DebugURL() string
DebugURL returns the Chrome remote debugging WebSocket URL.
func (*ChromeRemote) Evaluate ¶
func (cr *ChromeRemote) Evaluate(targetID string, jsExpr string, dest interface{}, timeoutMs int) error
Evaluate runs a JavaScript expression in the context of the given tab and unmarshals the result into dest (same semantics as chromedp.Evaluate). timeoutMs controls the per-call timeout; 0 uses a 15 s default.
func (*ChromeRemote) GetElements ¶
func (cr *ChromeRemote) GetElements(targetID string, targetURL string) ([]ElementInfo, error)
GetElements extracts information about clickable elements on the page. targetID can be empty to pick the best tab.
func (*ChromeRemote) GoBack ¶
func (cr *ChromeRemote) GoBack(targetID string) error
GoBack navigates back in browser history
func (*ChromeRemote) GoForward ¶
func (cr *ChromeRemote) GoForward(targetID string) error
GoForward navigates forward in browser history
func (*ChromeRemote) ListTabs ¶
func (cr *ChromeRemote) ListTabs() ([]TabInfo, error)
ListTabs lists all open tabs in Chrome
func (*ChromeRemote) Navigate ¶
func (cr *ChromeRemote) Navigate(targetID string, url string, waitUntil string, timeoutMs int) (*NavigationResult, error)
Navigate navigates a specific tab to a URL
func (*ChromeRemote) OpenTab ¶
func (cr *ChromeRemote) OpenTab(url string) (string, error)
OpenTab opens a new tab and returns its target ID. URL is optional.
func (*ChromeRemote) ReloadTab ¶
func (cr *ChromeRemote) ReloadTab(targetID string, bypassCache bool) error
ReloadTab reloads a specific tab
func (*ChromeRemote) TakeScreenshot ¶
func (cr *ChromeRemote) TakeScreenshot(targetID string, fullPage bool) ([]byte, error)
TakeScreenshot captures a screenshot of a specific tab (targetID). If targetID == "", it will try to pick a "best" tab (heuristic).
type ElementInfo ¶
type ElementInfo struct {
Selector string `json:"selector"` // CSS selector to use for clicking
TagName string `json:"tagName"` // HTML tag name (e.g., "button", "a", "input")
ID string `json:"id"` // Element ID attribute (if present)
Class string `json:"class"` // Element class attribute (if present)
Text string `json:"text"` // Visible text content
Type string `json:"type"` // Input type or button type (if applicable)
Href string `json:"href"` // Link href (for anchor tags)
Name string `json:"name"` // Name attribute (if present)
Aria string `json:"aria"` // ARIA label (if present)
Placeholder string `json:"placeholder"` // Placeholder text (for inputs)
}
ElementInfo represents information about a clickable element on the page
func GetChromeElements ¶
func GetChromeElements(debugURL string, targetURL string) ([]ElementInfo, error)
type NavigationResult ¶
type NavigationResult struct {
}
NavigationResult contains the result of a navigation operation
func NavigateToUrl ¶
type TabInfo ¶
type TabInfo struct {
ID string `json:"id"` // Target ID
Title string `json:"title"` // Page title
URL string `json:"url"` // Current URL
Type string `json:"type"` // Target type (usually "page")
Description string `json:"description"` // Description
}
TabInfo represents information about a Chrome tab