Browser
The Browser class in Ordino AI provides a suite of browser-level automation capabilities. It allows seamless interaction with browser windows, navigation, alerts, cookies, and more.
Usage : browser
browser🧩 Code
The Browser class is designed to interact with the browser
To insert a code block with syntax highlighting:
import { oi } from "@ordino.ai/spartify-engine";
oi.ui.browser().navigateToUrl('https://ordino.ai');import { oi } from "@ordino.ai/spartify-engine";
await oi.ui(this.page).browser().navigateToUrl('https://ordino')Navigation Methods
navigateToUrl(url: string): void
Navigates to the specified URL.
@param
url– The URL to navigate to.@returns
void
oi.ui.browser().navigateToUrl('https://ordino.ai');await oi.ui(this.page).browser().navigateToUrl('https://ordino.ai');refreshPage(): void
Refreshes the current page.
@returns
void
goBack(): void
Navigates back to the previous page.
@returns
void
goForward(): void
Navigates forward to the next page.
@returns
void
getCurrentUrl(): Chainable<String>
Retrieves the current URL
@returns
object<promise>
getPageTitle(): Chainable<String>
Retrieves the title of the current page.
@returns
object<promise>
assertUrl(expectedUrl: <String>): void
Asserts that the current URL matches the specified URL.
@param
url– The URL to navigate to.@returns
void
assertPageTitle(expectedTitle: <String>): void
Asserts that the current page title matches the specified title.
@param
title– The title to assert@returns
void
Browser Session & Storage
clearBrowserCache: void
Clears the browser cache.
@returns
void
clearBrowserCookies: void
Clears the browser cookies.
@returns
void
setBrowserCookie(name: string, value: string): void
Sets a browser cookie with the specified name and value.
@param
name– The name of the cookie.@param
value– The value of the cookie.@returns
void
getBrowserCookies(): Chainable<Cookie[]>
Retrieves all browser cookies.
@returns
object<promise>
Window & Frame Actions
setWindowSize(width: number, height: number): void
Sets the size of the browser window.
@param
width– The width of the window.@param
height– The height of the window.@returns
void
switchToWindow(windowName: string): void
Switches to the specified window.
@returns
void
switchToFrame(frameName: any): void
Retrieves all browser cookies.
@param
frame-name- The name or index of the frame to switch to.@returns
void
closeCurrentWindow(): void
Closes the current window.
@returns
void
openNewTab(url: string): void
Opens a new tab with the specified URL.
@param
url- The url to open in the new tab.@returns
void
assertBrowserIsOpen(): void
Asserts that the browser is open.
@returns
void
Screenshots & Alerts
takeScreenshot(fileName: string): void
Takes a screenshot and saves it with the specified file name.
@param
file-name- The name of the file to save the screenshot as@returns
void
takeFullPageScreenshot(fileName: string): void
Takes a full-page screenshot and saves it with the specified file name.
@param
frame-name- The name of the file to save the full-page screenshot as.@returns
void
handleAlert(alertText: string, action: string): void
Handles an alert with the specified text and action.
@param
alert-text- the text of the alert.@param
action- The action to take on the alert (e.g., accept, dismiss).@returns
void
Network Handling
waitForNetworkIdle(): void
Waits for the network to be idle.
@param
frame-name- The name or index of the frame to switch to.@returns
void
Last updated