Skip to content

Inconsistent navigation commands in documentation #7

@danieldaquino

Description

@danieldaquino

Thank you for creating a stagehand library for Rust! It has been very useful in a project I am building.

As I was using it, I noticed that the navigation methods in README.md and the example seem inconsistent with the stagehand documentation for other languages.

For example, this documentation page has the following code sample in TypeScript:

import { Stagehand } from "@browserbasehq/stagehand";

// Initialize with Browserbase (API key and project ID from environment variables)
// Set BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID in your environment
const stagehand = new Stagehand({ env: "BROWSERBASE" });
await stagehand.init();
const page = stagehand.context.pages()[0];

await page.goto("https://example.com");

// Simple action
await stagehand.act("click the login button");

However, the Rust library documentation uses the act call for navigation instead of goto. From README.md:

(...)

// 3. Navigate to a page
let mut act_stream = stagehand.act(
    "Go to https://quotes.toscrape.com/",
    None,
    HashMap::new(),
    Some(60_000),
    None,
).await?;

while let Some(res) = act_stream.next().await {
    if let Ok(response) = res {
        if let Some(ActResponseEvent::Success(success)) = response.event {
            println!("Navigation success: {}", success);
        }
    }
}

Furthermore, I ran the basic example using cargo run --example basic to test it and noticed that it did not seem to successfully navigate to HackerNews (the example website) by analyzing the Browserbase session.

However, there does seem to be a navigate command which seems to have worked when applied in the basic example. Here is the diff that I used to successfully run the basic example:

diff --git a/examples/basic.rs b/examples/basic.rs
index faa2cec..02eb117 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -1,7 +1,5 @@
 use stagehand_sdk::{
-    ActResponseEvent, AgentConfig, AgentExecuteOptions, Env, ExecuteResponseEvent,
-    ExtractResponseEvent, Model, ModelConfiguration, ObserveResponseEvent, Stagehand,
-    TransportChoice, V3Options,
+    ActResponseEvent, AgentConfig, AgentExecuteOptions, Env, ExecuteResponseEvent, ExtractResponseEvent, Model, ModelConfiguration, NavigateResponseEvent, ObserveResponseEvent, Stagehand, TransportChoice, V3Options
 };
 use futures::StreamExt;
 use serde::{Deserialize, Serialize};
@@ -44,19 +42,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
 
     // 3. Navigate to https://news.ycombinator.com
     println!("3. Navigating to Hacker News...");
-    let mut act_stream = stagehand
-        .act(
-            "Navigate to https://news.ycombinator.com",
-            None,
-            HashMap::new(),
-            Some(60_000),
-            None,
-        )
+    let mut nav_stream = stagehand
+        .navigate("https://news.ycombinator.com", None, None)
         .await?;
 
-    while let Some(res) = act_stream.next().await {
+    while let Some(res) = nav_stream.next().await {
         if let Ok(response) = res {
-            if let Some(ActResponseEvent::Success(success)) = response.event {
+            if let Some(NavigateResponseEvent::Success(success)) = response.event {
                 println!("   Navigation success: {}\n", success);
             }
         }

This seems to have worked. Is this an issue with the documentation and example implementation, or is the act call meant to be able to navigate as well in the Rust library?

Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions