Skip to main content

getUrl

codebolt.browser.getUrl(): Promise<UrlResponse>
Retrieves the current URL of the browser's active page.

Returns:

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

Example


// Navigate to the home page
await codebolt.browser.goToPage("https://example-website.com");

// Retrieve and log the current URL
let currentUrl = await codebolt.browser.getUrl();
console.log(`Current URL: ${currentUrl}`);

Explanation

The codebolt.browser.getUrl() function is used to retrieve the URL of the current web page in the browser. This function returns the url, which we can store in a variable and use.