Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Getgauge Taiko Goto

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Testing, Navigation
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for navigating the browser to a specified URL with configurable timeout and header options, provided by the Taiko library.

Description

goto is the primary page navigation function in Taiko. It instructs the browser to navigate to a given URL using the CDP Page.navigate command and waits for the page to finish loading. The function includes several intelligent behaviors:

  • Automatic protocol prefix — if the provided URL does not include a protocol scheme (e.g., http:// or https://), Taiko automatically prepends http://. This allows users to write goto('example.com') instead of goto('http://example.com').
  • Navigation waiting — by default, goto waits for the page to fully load before resolving. This includes waiting for the Page.loadEventFired and Page.frameStoppedLoading events.
  • Response tracking — the function tracks HTTP responses via the CDP Network domain and returns status information including the HTTP status code, status text, and any redirect responses encountered during navigation.
  • Custom headers — allows setting custom HTTP headers for the navigation request, useful for authentication tokens or API testing.
  • Configurable timeout — the navigationTimeout option controls how long Taiko waits for the page to load before throwing a timeout error.

Usage

Call goto(url) after openBrowser() to navigate to a web page. It is the standard way to load a page in both scripts and REPL sessions. The function should be awaited to ensure the page is fully loaded before performing subsequent interactions.

Code Reference

Source Location

  • Repository: Taiko
  • File: lib/taiko.js
  • Lines: L765-780

Signature

module.exports.goto = async (url, options = { navigationTimeout: defaultConfig.navigationTimeout }) => { ... }

Import

const { goto } = require('taiko');

I/O Contract

Inputs

Name Type Required Default Description
url string Yes The URL to navigate to. If no protocol scheme is provided, http:// is automatically prepended.
options Object No { navigationTimeout: 30000 } Configuration object for navigation behavior.
options.navigationTimeout number No 30000 Maximum time in milliseconds to wait for the page to load before throwing a timeout error.
options.headers Object No Custom HTTP headers to include with the navigation request. Keys are header names, values are header values.
options.waitForNavigation boolean No true Whether to wait for the page to fully load before resolving. When false, the function resolves immediately after issuing the navigate command.
options.waitForEvents string[] No Specific CDP events to wait for before considering navigation complete. Overrides the default load event behavior.
options.waitForStart number No 100 Time in milliseconds to wait for the navigation to actually start after issuing the command.

Outputs

Name Type Description
(return) Promise<Object> Resolves with a response object containing navigation results.
.url string The final URL after navigation (may differ from input due to redirects).
.status.code number The HTTP status code of the response (e.g., 200, 301, 404).
.status.text string The HTTP status text of the response (e.g., "OK", "Not Found").
.redirectedResponse Array Optional. An array of intermediate response objects encountered during redirects, if any redirects occurred.

Dependencies

  • CDP Page.navigate — the Chrome DevTools Protocol command used to initiate navigation
  • CDP Network domain — used for tracking HTTP responses and redirect chains

Usage Examples

Simple Navigation

// Auto-prefixed to http://example.com
await goto('example.com');

Full URL Navigation

await goto('https://example.com/login');

Custom Timeout

// Wait up to 60 seconds for slow pages
await goto('https://example.com', { navigationTimeout: 60000 });

Custom Headers

// Navigate with an authorization header
await goto('https://api.example.com', {
  headers: { 'Authorization': 'Bearer token123' }
});

Inspecting the Response

const response = await goto('https://example.com');
console.log(response.url);             // 'https://example.com/'
console.log(response.status.code);     // 200
console.log(response.status.text);     // 'OK'

Skip Waiting for Navigation

// Issue navigate command without waiting for load
await goto('https://example.com', { waitForNavigation: false });

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

See Also

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment