Skip to main content

Browser API

The browser module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
clickClicks on a specified element on the page.
closeCloses the current page.
closeBrowserInstanceClose a browser instance
enterSimulates the Enter key press on the current page.
executeOnInstanceExecute action on specific browser instance
extractTextExtracts text from the current page.
getBrowserInfoRetrieves browser info like height width scrollx scrolly of the current page.
getBrowserInstanceGet a specific browser instance by ID
getContentRetrieves the content of the current page.
getHTMLRetrieves the HTML content of the current page.
getMarkdownRetrieves the Markdown content of the current page.
getPDFRetrieves the PDF content of the current page.
getSnapShotRetrieves the snapshot of the current page.
getUrlRetrieves the current URL of the browser's active page.
goToPageNavigates to a specified URL.
listBrowserInstancesList all open browser instances
newPageOpens a new page in the browser.
openNewBrowserInstanceOpen a new browser instance
pdfToTextConverts the PDF content of the current page to text.
screenshotTakes a screenshot of the current page.
scrollScrolls the current page in a specified direction by a specified number of pixels.
searchPerforms a search on the current page using a specified query.
setActiveBrowserInstanceSet the active browser instance
typeTypes text into a specified element on the page.

Methods


click

plugin.browser.click(elementid: string, options?: BrowserOperationOptions): Promise<BrowserActionResponseData>

Clicks on a specified element on the page.

ParameterTypeRequiredDescription
elementidstringYesThe ID of the element to click.
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<BrowserActionResponseData> — A promise that resolves when the click action is complete.

Full reference →


close

plugin.browser.close(options?: BrowserOperationOptions): Promise<void>

Closes the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<void>

Full reference →


closeBrowserInstance

plugin.browser.closeBrowserInstance(instanceId: string): Promise<boolean>

Close a browser instance

ParameterTypeRequiredDescription
instanceIdstringYesThe instance ID to close

Returns: Promise<boolean> — True if successful, false if instance not found

Full reference →


enter

plugin.browser.enter(options?: BrowserOperationOptions): Promise<BrowserActionResponseData>

Simulates the Enter key press on the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<BrowserActionResponseData> — A promise that resolves when the Enter action is complete.

Full reference →


executeOnInstance

plugin.browser.executeOnInstance(instanceId: string, operation: BrowserOperationType, params: BrowserOperationParams): Promise<BrowserOperationResponse>

Execute action on specific browser instance

ParameterTypeRequiredDescription
instanceIdstringYesThe instance ID to execute on
operationBrowserOperationTypeYesThe operation to execute
paramsBrowserOperationParamsYesParameters for the operation

Returns: Promise<BrowserOperationResponse> — The operation result

Full reference →


extractText

plugin.browser.extractText(options?: BrowserOperationOptions): Promise<ExtractTextResponse>

Extracts text from the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<ExtractTextResponse> — A promise that resolves with the extracted text.

Full reference →


getBrowserInfo

plugin.browser.getBrowserInfo(options?: BrowserOperationOptions): Promise<BrowserInfoResponse>

Retrieves browser info like height width scrollx scrolly of the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<BrowserInfoResponse> — A promise that resolves with the browser info.

Full reference →


getBrowserInstance

plugin.browser.getBrowserInstance(instanceId: string): Promise<BrowserInstanceInfo | null>

Get a specific browser instance by ID

ParameterTypeRequiredDescription
instanceIdstringYesThe instance ID to get

Returns: Promise<BrowserInstanceInfo | null> — Browser instance information or null if not found

Full reference →


getContent

plugin.browser.getContent(options?: BrowserOperationOptions): Promise<GetContentResponse>

Retrieves the content of the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<GetContentResponse> — A promise that resolves with the content.

Full reference →


getHTML

plugin.browser.getHTML(options?: BrowserOperationOptions): Promise<HtmlReceived>

Retrieves the HTML content of the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<HtmlReceived> — A promise that resolves with the HTML content.

Full reference →


getMarkdown

plugin.browser.getMarkdown(options?: BrowserOperationOptions): Promise<GetMarkdownResponse>

Retrieves the Markdown content of the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<GetMarkdownResponse> — A promise that resolves with the Markdown content.

Full reference →


getPDF

plugin.browser.getPDF(options?: BrowserOperationOptions): Promise<void>

Retrieves the PDF content of the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<void>

Full reference →


getSnapShot

plugin.browser.getSnapShot(options?: BrowserOperationOptions): Promise<BrowserSnapshotResponse>

Retrieves the snapshot of the current page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<BrowserSnapshotResponse> — A promise that resolves with the snapshot.

Full reference →


getUrl

plugin.browser.getUrl(options?: BrowserOperationOptions): Promise<UrlResponse>

Retrieves the current URL of the browser's active page.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<UrlResponse> — A promise that resolves with the URL.

Full reference →


goToPage

plugin.browser.goToPage(url: string, options?: BrowserOperationOptions): Promise<GoToPageResponse>

Navigates to a specified URL.

ParameterTypeRequiredDescription
urlstringYesThe URL to navigate to.
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<GoToPageResponse> — A promise that resolves when navigation is complete.

Full reference →


listBrowserInstances

plugin.browser.listBrowserInstances(): Promise<BrowserInstanceInfo[]>

List all open browser instances

No parameters.

Returns: Promise<BrowserInstanceInfo[]> — Array of browser instance information

Full reference →


newPage

plugin.browser.newPage(options?: BrowserInstanceOptions): Promise<BrowserActionResponseData>

Opens a new page in the browser.

ParameterTypeRequiredDescription
optionsBrowserInstanceOptionsNoOptional browser instance options

Returns: Promise<BrowserActionResponseData>

Full reference →


openNewBrowserInstance

plugin.browser.openNewBrowserInstance(options?: BrowserInstanceOptions): Promise<object>

Open a new browser instance

ParameterTypeRequiredDescription
optionsBrowserInstanceOptionsNoOptional instance creation options

Returns: Promise<object> — The new instance ID

Full reference →


pdfToText

plugin.browser.pdfToText(options?: BrowserOperationOptions): Promise<void>

Converts the PDF content of the current page to text.

ParameterTypeRequiredDescription
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<void>

Full reference →


screenshot

plugin.browser.screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResponse>

Takes a screenshot of the current page.

ParameterTypeRequiredDescription
optionsBrowserScreenshotOptionsNoOptional browser screenshot options

Returns: Promise<BrowserScreenshotResponse>

Full reference →


scroll

plugin.browser.scroll(direction: string, pixels: string, options?: BrowserOperationOptions): Promise<BrowserActionResponseData>

Scrolls the current page in a specified direction by a specified number of pixels.

ParameterTypeRequiredDescription
directionstringYesThe direction to scroll.
pixelsstringYesThe number of pixels to scroll.
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<BrowserActionResponseData> — A promise that resolves when the scroll action is complete.

Full reference →


plugin.browser.search(elementid: string, query: string, options?: BrowserOperationOptions): Promise<BrowserActionResponseData>

Performs a search on the current page using a specified query.

ParameterTypeRequiredDescription
elementidstringYesThe ID of the element to perform the search in.
querystringYesThe search query.
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<BrowserActionResponseData> — A promise that resolves with the search results.

Full reference →


setActiveBrowserInstance

plugin.browser.setActiveBrowserInstance(instanceId: string): Promise<boolean>

Set the active browser instance

ParameterTypeRequiredDescription
instanceIdstringYesThe instance ID to set as active

Returns: Promise<boolean> — True if successful, false if instance not found

Full reference →


type

plugin.browser.type(elementid: string, text: string, options?: BrowserOperationOptions): Promise<BrowserActionResponseData>

Types text into a specified element on the page.

ParameterTypeRequiredDescription
elementidstringYesThe ID of the element to type into.
textstringYesThe text to type.
optionsBrowserOperationOptionsNoOptional browser operation options

Returns: Promise<BrowserActionResponseData> — A promise that resolves when the typing action is complete.

Full reference →