API Reference
Complete API reference for the Golang SDK. All types, functions, parameters, and return values.
Core Types
CloudBrowser
The main client for interacting with cloud browsers.
type CloudBrowser structHeader
HTTP header representation.
type Header struct
Name string
Value string
}Cookie
Browser cookie representation.
type Cookie struct
Name string
Value string
Domain string
Path string
}Request
Network request representation.
type Request struct
Method string
Url string
Headers []*Header
Body string
StatusCode int
}Response
Network response representation.
type Response struct
Url string
Headers []*Header
Body string
StatusCode int
}HeaderModification
Header modification for request interception.
type HeaderModification struct
Name string
Value string
Action HeaderModificationAction
After string
Before string
}HeaderModificationAction
Action type for header modifications.
type HeaderModificationAction int
const (
HeaderModificationAdd HeaderModificationAction = iota
HeaderModificationEdit
HeaderModificationRemove
}FrameTree
Frame tree structure for frame hierarchy.
type FrameTree struct
FrameId string
PosX int32
PosY int32
Children []*FrameTree
}Session Management
RentBrowser
Create a new cloud browser session.
func RentBrowser(ctx context.Context, apiKey string, rentTime int, proxyHost string, proxyPort int, proxyUsername string, proxyPassword string, countryCode string, timezone string, blobName string) (*CloudBrowser, error)Parameters:
ctx: Context for cancellationapiKey: WebRobotCloud API keyrentTime: Duration in seconds to rent the browserproxyHost: Proxy server hostnameproxyPort: Proxy server portproxyUsername: Proxy authentication usernameproxyPassword: Proxy authentication passwordcountryCode: Two-letter country code for proxy location (optional, "" for auto)timezone: Timezone string (optional, "" for auto)blobName: Name of the static file blob to use (optional, "" for no static files)
Returns:
*CloudBrowser: A configured browser instance ready for automationerror: Any error that occurred during browser creation
StopBrowser
Terminate an active browser session.
func StopBrowser(ctx context.Context, apiKey string, sessionId string) errorParameters:
ctx: Context for cancellationapiKey: WebRobotCloud API keysessionId: Session ID of the browser to stop
Note: You can also call browser.StopBrowser(ctx) on a CloudBrowser instance to stop the current session.
(*CloudBrowser) StopBrowser
Stop the current session and close the underlying gRPC connection.
func (c *CloudBrowser) StopBrowser(ctx context.Context) errorParameters:
ctx: Context for cancellation
Session Info
Access session metadata returned by the rent response.
func (c *CloudBrowser) GetSessionId() string
func (c *CloudBrowser) GetApiKey() string
func (c *CloudBrowser) GetGrpcUrl() string
func (c *CloudBrowser) GetCountryCode() string
func (c *CloudBrowser) GetTimezone() string
func (c *CloudBrowser) GetAcceptLanguage() stringClose
Convenience method to stop the browser session using a background context.
func (c *CloudBrowser) Close() errorUploadStaticFiles
Upload static files from a local directory to the WebRobotCloud server.
func UploadStaticFiles(ctx context.Context, apiKey string, blobName string, localPath string) errorParameters:
ctx: Context for cancellationapiKey: WebRobotCloud API keyblobName: Name of the blob to store the files underlocalPath: Local directory path containing files to upload
Returns:
error: Any error that occurred during the upload operation
Note: Each upload completely overwrites any previously uploaded static files for the given blob name. The newest upload replaces all previous files.
UploadStaticFilesFromFS
Upload static files from an fs.FS (including embed.FS) to the WebRobotCloud server.
func UploadStaticFilesFromFS(ctx context.Context, apiKey string, blobName string, filesystem fs.FS) errorParameters:
ctx: Context for cancellationapiKey: WebRobotCloud API keyblobName: Name of the blob to store the files underfilesystem: Filesystem containing files to upload (e.g., embed.FS)
Returns:
error: Any error that occurred during the upload operation
Note: Each upload completely overwrites any previously uploaded static files for the given blob name. The newest upload replaces all previous files.
Browser Operations
Navigate
Navigate to a URL with optional timeout.
func (c *CloudBrowser) Navigate(ctx context.Context, url string, timeoutMs int32) errorParameters:
ctx: Context for cancellationurl: URL to navigate totimeoutMs: Timeout in milliseconds
LoadHTML
Load HTML content directly into the browser.
func (c *CloudBrowser) LoadHTML(ctx context.Context, url string, html string) errorParameters:
ctx: Context for cancellationurl: URL to load the HTML content at (emulated)html: HTML content to load
ClickSelector
Click an element using CSS selector in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) ClickSelector(ctx context.Context, selector string) errorParameters:
ctx: Context for cancellationselector: CSS selector for the element
Note: If the element is inside an iframe, first find the frame (e.g. WaitForSelectorGlobal) and then use ClickSelectorInFrame.
ClickSelectorInFrame
Click an element using CSS selector inside a specific frame.
func (c *CloudBrowser) ClickSelectorInFrame(ctx context.Context, frameId string, selector string) errorParameters:
ctx: Context for cancellationframeId: Frame ID (or"ROOT_FRAME")selector: CSS selector for the element
FillInput
Fill an input field with a value in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) FillInput(ctx context.Context, selector string, value string) errorParameters:
ctx: Context for cancellationselector: CSS selector for the input elementvalue: Value to fill into the input field
FillInputInFrame
Fill an input field with a value inside a specific frame.
func (c *CloudBrowser) FillInputInFrame(ctx context.Context, frameId string, selector string, value string) errorParameters:
ctx: Context for cancellationframeId: Frame ID (or"ROOT_FRAME")selector: CSS selector for the input elementvalue: Value to fill into the input field
SelectOption
Select an option from a select element in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) SelectOption(ctx context.Context, selector string, option string) errorParameters:
ctx: Context for cancellationselector: CSS selector for the select elementoption: Option value or text to select
SelectOptionInFrame
Select an option from a select element inside a specific frame.
func (c *CloudBrowser) SelectOptionInFrame(ctx context.Context, frameId string, selector string, option string) errorParameters:
ctx: Context for cancellationframeId: Frame ID (or"ROOT_FRAME")selector: CSS selector for the select elementoption: Option value or text to select
Type
Type text into the currently focused element.
func (c *CloudBrowser) Type(ctx context.Context, text string) errorParameters:
ctx: Context for cancellationtext: Text to type into the focused element
Note: This method types into whatever element currently has focus. Use ClickSelector or FillInput first to focus an element if needed.
TypeInFrame
Type text into the currently focused element inside a specific frame.
func (c *CloudBrowser) TypeInFrame(ctx context.Context, frameId string, text string) errorParameters:
ctx: Context for cancellationframeId: Frame ID (or"ROOT_FRAME")text: Text to type into the focused element
Note: This method types into whatever element currently has focus in that frame. Focus an element first if needed.
MoveMouseToSelector
Move mouse to an element using CSS selector in the page's top frame (ROOT_FRAME). Returns the coordinates where the mouse was moved.
func (c *CloudBrowser) MoveMouseToSelector(ctx context.Context, selector string) (int32, int32, error)Parameters:
ctx: Context for cancellationselector: CSS selector for the element
Returns:
int32: X coordinateint32: Y coordinateerror: Any error that occurred
MoveMouseToSelectorInFrame
Move mouse to an element using CSS selector inside a specific frame.
func (c *CloudBrowser) MoveMouseToSelectorInFrame(ctx context.Context, frameId string, selector string) (int32, int32, error)Parameters:
ctx: Context for cancellationframeId: Frame ID (or"ROOT_FRAME")selector: CSS selector for the element
Returns:
int32: X coordinateint32: Y coordinateerror: Any error that occurred
PressPosition
Press mouse button at a specific position (x, y coordinates).
func (c *CloudBrowser) PressPosition(ctx context.Context, x int32, y int32) errorParameters:
ctx: Context for cancellationx: X coordinate to pressy: Y coordinate to press
ReleasePosition
Release mouse button at a specific position (x, y coordinates).
func (c *CloudBrowser) ReleasePosition(ctx context.Context, x int32, y int32) errorParameters:
ctx: Context for cancellationx: X coordinate to releasey: Y coordinate to release
JavaScript Execution
Evaluate
Execute JavaScript expression and return the result in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) Evaluate(ctx context.Context, expression string) (interface, error)Parameters:
ctx: Context for cancellationexpression: JavaScript expression to execute
Returns:
interface: Result of the JavaScript expressionerror: Any error that occurred during execution
EvaluateInFrame
Execute JavaScript expression and return the result in a specific frame.
func (c *CloudBrowser) EvaluateInFrame(ctx context.Context, expression string, frameId string) (interface, error)Parameters:
ctx: Context for cancellationexpression: JavaScript expression to executeframeId: Frame ID to execute in
Returns:
interface: Result of the JavaScript expressionerror: Any error that occurred during execution
Waiting Operations
Frame Targeting Modes
The waiting operations support three frame targeting modes:
- Default methods (
WaitFor...): Search only in the page's top frame (ROOT_FRAME) - Global methods (
WaitFor...Global): Search across all frames globally - Frame-specific methods (
WaitFor...InFrame): Search only in a specific frame
WaitForSelector
Wait for an element to appear in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) WaitForSelector(ctx context.Context, selector string, timeoutMs int32) errorParameters:
ctx: Context for cancellationselector: CSS selector to wait fortimeoutMs: Timeout in milliseconds
Returns:
error: Any error that occurred during the wait operation
WaitForSelectorGlobal
Wait for an element to appear and return the frame ID where it was found. Searches across all frames globally.
func (c *CloudBrowser) WaitForSelectorGlobal(ctx context.Context, selector string, timeoutMs int32) (string, error)Parameters:
ctx: Context for cancellationselector: CSS selector to wait fortimeoutMs: Timeout in milliseconds
Returns:
string: Frame ID where the selector was founderror: Any error that occurred during the wait operation
WaitForExpression
Wait for a JavaScript expression to return true in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) WaitForExpression(ctx context.Context, expression string, timeoutMs int32) errorParameters:
ctx: Context for cancellationexpression: JavaScript expression to wait fortimeoutMs: Timeout in milliseconds
Returns:
error: Any error that occurred during the wait operation
WaitForExpressionGlobal
Wait for a JavaScript expression to return true and return the frame ID where it was found. Searches across all frames globally.
func (c *CloudBrowser) WaitForExpressionGlobal(ctx context.Context, expression string, timeoutMs int32) (string, error)Parameters:
ctx: Context for cancellationexpression: JavaScript expression to wait fortimeoutMs: Timeout in milliseconds
Returns:
string: Frame ID where the expression returned trueerror: Any error that occurred during the wait operation
WaitForAnySelector
Wait for any of multiple selectors to appear in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) WaitForAnySelector(ctx context.Context, selectors []string, timeoutMs int32) (int32, error)Parameters:
ctx: Context for cancellationselectors: Array of CSS selectors to wait fortimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the first matching selectorerror: Any error that occurred during the wait operation
WaitForAnySelectorGlobal
Wait for any of multiple selectors to appear and return the frame ID where it was found. Searches across all frames globally.
func (c *CloudBrowser) WaitForAnySelectorGlobal(ctx context.Context, selectors []string, timeoutMs int32) (int32, string, error)Parameters:
ctx: Context for cancellationselectors: Array of CSS selectors to wait fortimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the first matching selectorstring: Frame ID where the selector was founderror: Any error that occurred during the wait operation
WaitForAnyExpression
Wait for any of multiple JavaScript expressions to return true in the page's top frame (ROOT_FRAME).
func (c *CloudBrowser) WaitForAnyExpression(ctx context.Context, expressions []string, timeoutMs int32) (int32, error)Parameters:
ctx: Context for cancellationexpressions: Array of JavaScript expressions to wait fortimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the first matching expressionerror: Any error that occurred during the wait operation
WaitForAnyExpressionGlobal
Wait for any of multiple JavaScript expressions to return true and return the frame ID where it was found. Searches across all frames globally.
func (c *CloudBrowser) WaitForAnyExpressionGlobal(ctx context.Context, expressions []string, timeoutMs int32) (int32, string, error)Parameters:
ctx: Context for cancellationexpressions: Array of JavaScript expressions to wait fortimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the first matching expressionstring: Frame ID where the expression returned trueerror: Any error that occurred during the wait operation
WaitForSelectorInFrame
Wait for an element to appear in a specific frame (not children). Use this when you know the exact frame ID.
func (c *CloudBrowser) WaitForSelectorInFrame(ctx context.Context, frameId string, selector string, timeoutMs int32) (string, error)Parameters:
ctx: Context for cancellationframeId: Frame ID to search in (can be a specific frame ID or "ROOT_FRAME" for the page's top frame)selector: CSS selector to wait fortimeoutMs: Timeout in milliseconds
Returns:
string: Frame ID where the selector was founderror: Any error that occurred during the wait operation
WaitForExpressionInFrame
Wait for a JavaScript expression to return true in a specific frame (not children). Use this when you know the exact frame ID.
func (c *CloudBrowser) WaitForExpressionInFrame(ctx context.Context, frameId string, expression string, timeoutMs int32) (string, error)Parameters:
ctx: Context for cancellationframeId: Frame ID to search in (can be a specific frame ID or "ROOT_FRAME" for the page's top frame)expression: JavaScript expression to wait fortimeoutMs: Timeout in milliseconds
Returns:
string: Frame ID where the expression returned trueerror: Any error that occurred during the wait operation
WaitForAnySelectorInFrame
Wait for any of multiple selectors to appear in a specific frame (not children). Use this when you know the exact frame ID.
func (c *CloudBrowser) WaitForAnySelectorInFrame(ctx context.Context, frameId string, selectors []string, timeoutMs int32) (int32, string, error)Parameters:
ctx: Context for cancellationframeId: Frame ID to search in (can be a specific frame ID or "ROOT_FRAME" for the page's top frame)selectors: Array of CSS selectors to wait fortimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the first matching selectorstring: Frame ID where the selector was founderror: Any error that occurred during the wait operation
WaitForAnyExpressionInFrame
Wait for any of multiple JavaScript expressions to return true in a specific frame (not children). Use this when you know the exact frame ID.
func (c *CloudBrowser) WaitForAnyExpressionInFrame(ctx context.Context, frameId string, expressions []string, timeoutMs int32) (int32, string, error)Parameters:
ctx: Context for cancellationframeId: Frame ID to search in (can be a specific frame ID or "ROOT_FRAME" for the page's top frame)expressions: Array of JavaScript expressions to wait fortimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the first matching expressionstring: Frame ID where the expression returned trueerror: Any error that occurred during the wait operation
Frame Management
GetFrames
Get all available frame IDs.
func (c *CloudBrowser) GetFrames(ctx context.Context) ([]string, error)Parameters:
ctx: Context for cancellation
Returns:
[]string: Array of frame IDserror: Any error that occurred during the operation
GetFrameTree
Get the frame tree structure showing the hierarchy of all frames.
func (c *CloudBrowser) GetFrameTree(ctx context.Context) (*FrameTree, error)Parameters:
ctx: Context for cancellation
Returns:
*FrameTree: Frame tree structureerror: Any error that occurred during the operation
Network Operations
WaitForRequest
Wait for a specific network request.
func (c *CloudBrowser) WaitForRequest(ctx context.Context, url string, abort bool, timeoutMs int32) (*Request, error)Parameters:
ctx: Context for cancellationurl: URL pattern to wait forabort: Whether to abort the requesttimeoutMs: Timeout in milliseconds
Returns:
*Request: Request object with method, URL, headers, body, and status codeerror: Any error that occurred during the wait operation
WaitForResponse
Wait for a specific network response.
func (c *CloudBrowser) WaitForResponse(ctx context.Context, url string, timeoutMs int32) (*Response, error)Parameters:
ctx: Context for cancellationurl: URL pattern to wait fortimeoutMs: Timeout in milliseconds
Returns:
*Response: Response object with URL, headers, body, and status codeerror: Any error that occurred during the wait operation
WaitForAnyRequest
Wait for any of multiple network requests.
func (c *CloudBrowser) WaitForAnyRequest(ctx context.Context, urlPatterns []string, abortFlags []bool, timeoutMs int32) (int32, *Request, error)Parameters:
ctx: Context for cancellationurlPatterns: Array of URL patterns to wait forabortFlags: Array of abort flags corresponding to each URL patterntimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the matching request*Request: Request object with method, URL, headers, body, and status codeerror: Any error that occurred during the wait operation
WaitForAnyResponse
Wait for any of multiple network responses.
func (c *CloudBrowser) WaitForAnyResponse(ctx context.Context, urlPatterns []string, timeoutMs int32) (int32, *Response, error)Parameters:
ctx: Context for cancellationurlPatterns: Array of URL patterns to wait fortimeoutMs: Timeout in milliseconds
Returns:
int32: Index of the matching response*Response: Response object with URL, headers, body, and status codeerror: Any error that occurred during the wait operation
ModifyRequest
Modify network requests by adding, editing, or removing headers and optionally changing the request body.
func (c *CloudBrowser) ModifyRequest(ctx context.Context, urlPattern string, timeoutMs int32, modifications []*HeaderModification, body string) (*Request, error)Parameters:
ctx: Context for cancellationurlPattern: URL pattern to match requests for modificationtimeoutMs: Timeout in millisecondsmodifications: Array of header modifications to applybody: Optional new request body (only applies to POST requests)
Returns:
*Request: Modified request objecterror: Any error that occurred during the modification operation
SetBlockList
Set URL patterns to block. Requests matching these patterns will be blocked.
func (c *CloudBrowser) SetBlockList(ctx context.Context, patterns []string) errorParameters:
ctx: Context for cancellationpatterns: Array of URL patterns to block (supports wildcard*)
Returns:
error: Any error that occurred during the operation
Cookie Management
GetCookies
Get all browser cookies.
func (c *CloudBrowser) GetCookies(ctx context.Context) ([]*Cookie, error)Parameters:
ctx: Context for cancellation
Returns:
[]*Cookie: Array of cookie objectserror: Any error that occurred during the operation
SetCookies
Set cookies for the current browser session.
func (c *CloudBrowser) SetCookies(ctx context.Context, cookies []*Cookie) errorParameters:
ctx: Context for cancellationcookies: Cookies to set (name, value, domain, path)
Returns:
error: Any error that occurred during the operation
ClearCookies
Clear all cookies for the current browser session.
func (c *CloudBrowser) ClearCookies(ctx context.Context) errorParameters:
ctx: Context for cancellation
Returns:
error: Any error that occurred during the operation
Captcha Solving
SolveCaptcha
Attempt to auto-detect and solve a supported captcha on the current page (PerimeterX, Cloudflare Turnstile, DataDome).
func (c *CloudBrowser) SolveCaptcha(ctx context.Context, timeoutMs int32, retryAmount ...int32) (string, error)Parameters:
ctx: Context for cancellationtimeoutMs: Overall timeout in milliseconds (0 uses default)retryAmount: Optional retry budget (primarily for Px). If omitted, SDK uses a default.
Returns:
string: Empty string on success; error-like string on failureerror: Transport/handling error (if any)