> ## Documentation Index
> Fetch the complete documentation index at: https://docs.narada.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# go_to_url

> Navigate browser windows to specific URLs programmatically using the Narada Python SDK

The `go_to_url` method provides a simple, reliable way to navigate browser windows to specific URLs programmatically. Use this method to set up automation workflows that need to start from specific web pages or navigate between different sites during task execution.

<Note>
  The `go_to_url` method waits for the navigation to complete before returning. This makes it useful for setting up initial page states or navigating between pages in multi-step workflows.
</Note>

## Method Signature

```python theme={null}
async def go_to_url(
    self,
    *,
    url: str,
    new_tab: bool = False,
    timeout: int | None = None,
) -> None
```

## Parameters

<ParamField query="url" type="str" required>
  The target URL to navigate to. Must be a valid HTTP or HTTPS URL.

  ```python theme={null}
  url="https://www.google.com"
  url="https://arxiv.org/list/cs.AI/recent"
  ```
</ParamField>

<ParamField query="new_tab" type="bool" default="False">
  Whether to open the URL in a new tab instead of navigating the current tab.

  ```python theme={null}
  new_tab=False  # Navigate current tab (default)
  new_tab=True   # Open in new tab
  ```
</ParamField>

<ParamField query="timeout" type="int | None" default="None">
  Maximum time in seconds to wait for navigation to complete. If `None`, uses the default system timeout.

  ```python theme={null}
  timeout=30     # Wait up to 30 seconds
  timeout=None   # Use default timeout
  ```
</ParamField>

## Return Value

This method returns `None` and completes when the navigation is successful.

## Example

```python theme={null}
import asyncio

from narada import Agent, BrowserEnvironment

async def main():
    env = BrowserEnvironment()
    agent = Agent(environment=env)

    try:
        # Navigate to a specific page
        await agent.go_to_url(url="https://www.google.com")

        # Now perform actions on the current page
        response = await agent.run(
            prompt="search for 'python automation' and get the first result"
        )

        print(f"Result: {response.text}")
    finally:
        await env.close()

if __name__ == "__main__":
    asyncio.run(main())
```

## Common Use Cases

<CardGroup cols={2}>
  <Card title="Workflow Setup" icon="arrow-right">
    **Navigate to starting pages**

    * Set up initial page state
    * Navigate to login pages
    * Access specific application sections
    * Load data entry forms
  </Card>

  <Card title="Multi-Page Analysis" icon="files">
    **Compare across multiple sources**

    * Open comparison sites in new tabs
    * Gather data from different pages
    * Cross-reference information
    * Aggregate research findings
  </Card>

  <Card title="Sequential Processing" icon="list">
    **Process items one by one**

    * Navigate through search results
    * Visit each item in a list
    * Process form submissions
    * Follow workflow steps
  </Card>

  <Card title="Resource Collection" icon="download">
    **Gather resources systematically**

    * Download files from multiple sources
    * Collect images or documents
    * Archive web content
    * Build resource libraries
  </Card>
</CardGroup>

## Best Practices

<CardGroup cols={2}>
  <Card title="URL Validation" icon="check-circle">
    Always use complete, valid URLs with protocol (https\://) for reliable navigation
  </Card>

  <Card title="Timeout Management" icon="clock">
    Set appropriate timeouts for slow-loading pages or unreliable network conditions
  </Card>

  <Card title="Error Handling" icon="shield">
    Implement proper error handling for navigation failures and network issues
  </Card>

  <Card title="Tab Management" icon="window">
    Use `new_tab=True` strategically to keep important pages open for reference
  </Card>
</CardGroup>

## Error Handling

The `go_to_url` method can raise the following exceptions:

<Accordion title="NaradaTimeoutError">
  Raised when navigation exceeds the specified timeout period.

  ```python theme={null}
  from narada import NaradaTimeoutError

  try:
      await agent.go_to_url(url="https://slow-loading-site.com", timeout=10)
  except NaradaTimeoutError:
      print("Navigation timed out after 10 seconds")
  ```
</Accordion>

<Accordion title="NaradaError">
  Raised for general navigation errors (invalid URLs, network issues, etc.).

  ```python theme={null}
  from narada import NaradaError

  try:
      await agent.go_to_url(url="https://invalid-url")
  except NaradaError as e:
      print(f"Navigation failed: {e}")
  ```
</Accordion>

## Integration with Other Methods

The `go_to_url` method works seamlessly with other agent methods:

```python theme={null}
# Navigate then perform actions
await agent.go_to_url(url="https://example.com")
await agent.run(prompt="fill out the contact form")

# Navigate then use selectors
await agent.go_to_url(url="https://app.example.com")
await agent.agentic_selector(
    action={"type": "click"},
    selectors={"aria_label": "Login"},
    fallback_operator_query="click the login button"
)

# Navigate then read data
await agent.go_to_url(url="https://sheets.google.com/spreadsheet/123")
data = await agent.read_google_sheet(
    spreadsheet_id="123",
    range="A1:C10"
)
```

## Performance Considerations

<Note>
  The `go_to_url` method waits for the page to fully load before returning. For pages with heavy JavaScript or many resources, consider using appropriate timeout values to avoid long wait times.
</Note>

<Tip>
  When working with multiple pages, consider opening them in new tabs rather than navigating back and forth, which can be more efficient for comparison tasks.
</Tip>
