Skip to main content

goto()

Navigate to a URL and wait for visual stability. Prefer this over opensteer.page.goto() for consistent post-navigation settling.
await opensteer.goto(url: string, options?: GotoOptions)

Parameters

url
string
required
The URL to navigate to. Can be absolute or relative (relative to current page).
timeout
number
Maximum navigation time in milliseconds. Default: 30000 (30 seconds)
waitUntil
'commit' | 'domcontentloaded' | 'load' | 'networkidle'
When to consider navigation succeeded:
  • commit - navigation committed (fastest)
  • domcontentloaded - DOMContentLoaded event fired
  • load - load event fired (default)
  • networkidle - no network connections for at least 500ms
settleMs
number
Additional wait time in milliseconds after the page load event. Default: 1000ms

Examples

Basic navigation

await opensteer.goto('https://example.com')

Wait for network idle

await opensteer.goto('https://example.com', {
  waitUntil: 'networkidle',
  settleMs: 1500
})

Fast navigation

await opensteer.goto('https://example.com', {
  waitUntil: 'commit',
  settleMs: 0
})
try {
  await opensteer.goto('https://slow-site.com', {
    timeout: 60000, // 60 seconds
    waitUntil: 'load'
  })
} catch (error) {
  console.error('Navigation timeout:', error)
}

Browser history navigation

For browser history operations like reload, back, and forward, use the Playwright page property:
// Reload the current page
await opensteer.page.reload()

// Go back in history
await opensteer.page.goBack()

// Go forward in history
await opensteer.page.goForward()

Example

await opensteer.goto('https://example.com')
await opensteer.goto('https://example.com/about')

// Navigate back
await opensteer.page.goBack()

const { url } = await opensteer.state()
console.log(url) // https://example.com

// Navigate forward
await opensteer.page.goForward()

waitForVisualStability()

Wait for the page to become visually stable (exported utility function).
import { waitForVisualStability } from 'opensteer'

await waitForVisualStability(page, options?)

Parameters

page
Page
required
Playwright Page instance.
options
object

Example

import { chromium } from 'playwright'
import { waitForVisualStability } from 'opensteer'

const browser = await chromium.launch()
const page = await browser.newPage()

await page.goto('https://example.com')
await waitForVisualStability(page, { settleMs: 2000 })

console.log('Page is stable')

Multi-page workflow

const opensteer = new Opensteer({ name: 'multi-page' })
await opensteer.launch()

try {
  // Navigate to first page
  await opensteer.goto('https://example.com')
  await opensteer.click({ description: 'login button' })
  
  // Navigate to second page
  await opensteer.goto('https://example.com/dashboard')
  const data = await opensteer.extract({
    schema: { username: 'string' }
  })
  
  // Use Playwright page for history navigation
  await opensteer.page.goBack()
  await opensteer.page.goForward()
  
} finally {
  await opensteer.close()
}

Handle navigation errors

try {
  await opensteer.goto('https://example.com', {
    timeout: 15000,
    waitUntil: 'networkidle'
  })
} catch (error) {
  if (error.message.includes('timeout')) {
    console.error('Page took too long to load')
    // Retry with faster settings
    await opensteer.goto('https://example.com', {
      waitUntil: 'domcontentloaded',
      settleMs: 500
    })
  } else {
    throw error
  }
}

SPA navigation

For single-page applications where the URL changes without a full page load:
// Initial navigation
await opensteer.goto('https://spa-app.com')

// Click changes URL but doesn't reload
await opensteer.click({ description: 'about link' })

// Wait for stability after client-side navigation
await waitForVisualStability(opensteer.page)

// Or use a manual wait
await opensteer.page.waitForTimeout(1000)

Best practices

Use goto() instead of page.goto() for automatic visual stability detection.
The default settleMs: 1000 works for most pages. Increase it for pages with animations or dynamic content.
Network idle can be unreliable for pages with long-polling or WebSocket connections. Use load or domcontentloaded instead.