Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions internal/cmd/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,6 @@ func init() {
pageUploadCmd.Flags().StringVar(&pageUploadFile, "file", "", "Path to the file to upload (required)")
_ = pageUploadCmd.MarkFlagRequired("file")

// observe flags
pageObserveCmd.Flags().StringVar(&sessionObserveURL, "url", "", "Navigate to URL before observing")

// scrape flags
pageScrapeCmd.Flags().StringVar(&sessionScrapeInstructions, "instructions", "", "Extraction instructions")
pageScrapeCmd.Flags().BoolVar(&sessionScrapeOnlyMain, "only-main-content", false, "Only scrape main content")
Expand Down
23 changes: 0 additions & 23 deletions internal/cmd/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,29 +625,6 @@ func TestRunPageObserve(t *testing.T) {
}
}

func TestRunPageObserve_WithURL(t *testing.T) {
server := setupPageTest(t)
server.AddResponse("/sessions/"+pageSessionIDTest+"/page/observe", 200, pageObserveResponse())

origURL := sessionObserveURL
sessionObserveURL = "https://example.com"
t.Cleanup(func() { sessionObserveURL = origURL })

cmd := &cobra.Command{}
cmd.SetContext(context.Background())

stdout, _ := testutil.CaptureOutput(func() {
err := runSessionObserve(cmd, []string{})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
})

if stdout == "" {
t.Error("expected output, got empty string")
}
}

// Other Actions Tests

func TestRunPageCaptchaSolve(t *testing.T) {
Expand Down
6 changes: 0 additions & 6 deletions internal/cmd/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var sessionsStartProxies bool

var (
sessionID string
sessionObserveURL string
sessionExecuteAction string
sessionScrapeInstructions string
sessionScrapeOnlyMain bool
Expand Down Expand Up @@ -294,8 +293,6 @@ func init() {

// Observe command flags
sessionsObserveCmd.Flags().StringVar(&sessionID, "session-id", "", "Session ID (uses current session if not specified)")
sessionsObserveCmd.Flags().StringVar(&sessionObserveURL, "url", "", "Navigate to URL before observing")

// Execute command flags
sessionsExecuteCmd.Flags().StringVar(&sessionID, "session-id", "", "Session ID (uses current session if not specified)")
sessionsExecuteCmd.Flags().StringVar(&sessionExecuteAction, "action", "", "Action JSON, @file, or '-' for stdin")
Expand Down Expand Up @@ -545,9 +542,6 @@ func runSessionObserve(cmd *cobra.Command, args []string) error {
defer cancel()

body := api.PageObserveJSONRequestBody{}
if sessionObserveURL != "" {
body.Url = &sessionObserveURL
}

params := &api.PageObserveParams{}
resp, err := client.Client().PageObserveWithResponse(ctx, sessionID, params, body)
Expand Down
32 changes: 0 additions & 32 deletions internal/cmd/sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,38 +322,6 @@ func TestRunSessionObserve(t *testing.T) {
observeResp := fmt.Sprintf(`{"metadata":{"tabs":[{"tab_id":1,"title":"Tab","url":"https://example.com"}],"title":"Tab","url":"https://example.com"},"screenshot":{"raw":"aGVsbG8="},"session":%s,"space":{"category":"page","description":"desc","interaction_actions":[]}}`, sessionJSON())
server.AddResponse("/sessions/"+sessionIDTest+"/page/observe", 200, observeResp)

origURL := sessionObserveURL
sessionObserveURL = "https://example.com"
t.Cleanup(func() { sessionObserveURL = origURL })

origFormat := outputFormat
outputFormat = "json"
t.Cleanup(func() { outputFormat = origFormat })

cmd := &cobra.Command{}
cmd.SetContext(context.Background())

stdout, _ := testutil.CaptureOutput(func() {
err := runSessionObserve(cmd, nil)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
})

if stdout == "" {
t.Error("expected output, got empty string")
}
}

func TestRunSessionObserve_NoURL(t *testing.T) {
server := setupSessionTest(t)
observeResp := fmt.Sprintf(`{"metadata":{"tabs":[{"tab_id":1,"title":"Tab","url":"https://example.com"}],"title":"Tab","url":"https://example.com"},"screenshot":{"raw":"aGVsbG8="},"session":%s,"space":{"category":"page","description":"desc","interaction_actions":[]}}`, sessionJSON())
server.AddResponse("/sessions/"+sessionIDTest+"/page/observe", 200, observeResp)

origURL := sessionObserveURL
sessionObserveURL = ""
t.Cleanup(func() { sessionObserveURL = origURL })

origFormat := outputFormat
outputFormat = "json"
t.Cleanup(func() { outputFormat = origFormat })
Expand Down
2 changes: 1 addition & 1 deletion skills/notte-browser/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ notte page close-tab
**Page State:**
```bash
# Observe page state and available actions
notte page observe [--url <url>]
notte page observe

# Save a screenshot in tmp folder
notte page screenshot
Expand Down
36 changes: 28 additions & 8 deletions tests/integration/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ func TestPageObserve(t *testing.T) {
// Wait for session to be ready
time.Sleep(2 * time.Second)

// Observe a page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
// Navigate to the page first
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

// Observe the page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)

// Verify we got some observation data
Expand Down Expand Up @@ -54,7 +58,10 @@ func TestPageExecuteAction(t *testing.T) {
time.Sleep(2 * time.Second)

// First navigate to a page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)

// Execute a simple goto action
Expand Down Expand Up @@ -82,7 +89,10 @@ func TestPageScrapeBasic(t *testing.T) {
time.Sleep(2 * time.Second)

// Navigate to a page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)

// Scrape the page
Expand Down Expand Up @@ -114,7 +124,10 @@ func TestPageScrapeWithInstructions(t *testing.T) {
time.Sleep(2 * time.Second)

// Navigate to a page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)

// Scrape with specific instructions
Expand All @@ -141,7 +154,10 @@ func TestPageScrapeOnlyMainContent(t *testing.T) {
time.Sleep(2 * time.Second)

// Navigate to a page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)

// Scrape only main content
Expand All @@ -167,8 +183,12 @@ func TestPageObserveExecuteScrapeFlow(t *testing.T) {
// Wait for session to be ready
time.Sleep(2 * time.Second)

// Step 1: Observe initial page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
// Step 1: Navigate to initial page
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

// Step 1b: Observe initial page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)
t.Log("Step 1: Observed initial page")

Expand Down
18 changes: 14 additions & 4 deletions tests/integration/sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ func TestSessionsObserve(t *testing.T) {
// Wait a moment for the session to be fully ready
time.Sleep(2 * time.Second)

// Observe the page (navigate to a URL)
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
// Navigate to a URL
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

// Observe the page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)
t.Log("Successfully observed page")
}
Expand All @@ -136,7 +140,10 @@ func TestSessionsScrape(t *testing.T) {
time.Sleep(2 * time.Second)

// First navigate to a page
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)

// Scrape the page content
Expand All @@ -163,7 +170,10 @@ func TestSessionsNetwork(t *testing.T) {
time.Sleep(2 * time.Second)

// Navigate to generate some network activity
result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID, "--url", "https://example.com")
result = runCLIWithTimeout(t, 120*time.Second, "page", "goto", "https://example.com", "--session-id", sessionID)
requireSuccess(t, result)

result = runCLIWithTimeout(t, 120*time.Second, "sessions", "observe", "--session-id", sessionID)
requireSuccess(t, result)

// Get network logs
Expand Down