goToPage
codebolt.browser.goToPage(url: string): Promise<GoToPageResponse>
Navigates the browser to a specific URL.
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL to navigate to (must include protocol like https://). |
Example
// Wait for connection and create a new page
await codebolt.waitForConnection();
await codebolt.browser.newPage();
// Navigate to a webpage
const goToResult = await codebolt.browser.goToPage('https://example.com');
console.log('✅ Navigated to page:', goToResult);
// Wait for the page to fully load
await new Promise(resolve => setTimeout(resolve, 2000));
// Verify the navigation was successful
const currentUrl = await codebolt.browser.getUrl();
console.log('✅ Current URL after navigation:', currentUrl);
// Example with different websites
await codebolt.browser.goToPage('https://www.google.com');
await codebolt.browser.goToPage('https://github.com');
Response Structure
The method returns a Promise that resolves to a GoToPageResponse
object with the following properties:
Response Properties:
type
: Always "goToPageResponse"url
: Optional string containing the URL that was navigated tosuccess
: Optional boolean indicating if the navigation was successfulmessage
: Optional string with additional informationerror
: Optional string containing error details if the operation failedmessageId
: Optional unique identifier for the messagethreadId
: Optional thread identifier
Explanation
The codebolt.browser.goToPage(url)
function navigates the browser to a specified URL. This is one of the most fundamental browser automation functions, allowing you to load different web pages programmatically.