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
oi.ui.browser().refreshPage('https://ordino.ai');await oi.ui(this.page).browser().refreshPage()goBack(): void
Navigates back to the previous page.
@returns
void
oi.ui.browser().goBack();await oi.ui(this.page).browser().goBack()goForward(): void
Navigates forward to the next page.
@returns
void
oi.ui.browser().goForward();await oi.ui(this.page).browser().goForward()getCurrentUrl(): Chainable<String>
Retrieves the current URL
@returns
object<promise>
oi.ui.browser().getCurrentUrl().then((url) => {
console.log('Current URL:', url);
});await oi.ui(this.page).browser().getCurrentUrl()getPageTitle(): Chainable<String>
Retrieves the title of the current page.
@returns
object<promise>
oi.ui.browser().getPageTitle().then((title) => {
console.log('Page Title:', title);
});await oi.ui(this.page).browser().getPageTitle()assertUrl(expectedUrl: <String>): void
Asserts that the current URL matches the specified URL.
@param
url– The URL to navigate to.@returns
void
oi.ui.browser().assertUrl('https://ordino.ai');await oi.ui(this.page).browser().assertUrl('')assertPageTitle(expectedTitle: <String>): void
Asserts that the current page title matches the specified title.
@param
title– The title to assert@returns
void
oi.ui.browser().assertPageTitle('Ordino - Home');await oi.ui(this.page).browser().assertPageTitle('')Browser Session & Storage
clearBrowserCache: void
Clears the browser cache.
@returns
void
oi.ui.browser().clearBrowserCache();await oi.ui(this.page).browser().clearBrowserCache()clearBrowserCookies: void
Clears the browser cookies.
@returns
void
oi.ui.browser().clearBrowserCookies();await oi.ui(this.page).browser().clearBrowserCookies()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
oi.ui.browser().setBrowserCookie('sessionId', '12345');await oi.ui(this.page).browser().setBrowserCookie('','')getBrowserCookies(): Chainable<Cookie[]>
Retrieves all browser cookies.
@returns
object<promise>
oi.ui.browser().getBrowserCookies().then((cookies) => {
console.log('Cookies:', cookies);
});await oi.ui(this.page).browser().getBrowserCookies()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
oi.ui.browser().setWindowSize(1280, 720);await oi.ui(this.page).browser().setWindowSize(1280, 720)switchToWindow(windowName: string): void
Switches to the specified window.
@returns
void
oi.ui.browser().switchToWindow('newWindow');await oi.ui(this.page).browser().switchToWindow('newWindow')switchToFrame(frameName: any): void
Retrieves all browser cookies.
@param
frame-name- The name or index of the frame to switch to.@returns
void
ui.browser().switchToFrame('iframe-id');await oi.ui(this.page).browser().switchToFrame('')closeCurrentWindow(): void
Closes the current window.
@returns
void
ui.browser().closeCurrentWindow();await oi.ui(this.page).browser().closeCurrentWindow()openNewTab(url: string): void
Opens a new tab with the specified URL.
@param
url- The url to open in the new tab.@returns
void
ui.browser().openNewTab('https://ordino.ai');await oi.ui(this.page).browser().openNewTab('https://ordino.ai')assertBrowserIsOpen(): void
Asserts that the browser is open.
@returns
void
ui.browser().oi.ui.browser.assertBrowserIsOpen();await oi.ui(this.page).browser().assertBrowserIsOpen()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
ui.browser().takeScreenshot('homepage');await oi.ui(this.page).browser().takeScreenshot('')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
ui.browser().takeFullPageScreenshot('full-homepage');await oi.ui(this.page).browser().takeFullPageScreenshot('')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
ui.browser().handleAlert('Confirm Delete?', 'accept');await oi.ui(this.page).browser().handleAlert(action: "accept" | "dismiss")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
ui.browser().waitForNetworkIdle();await oi.ui(this.page).browser().waitForNetworkIdle()Last updated