Skip to content

Commit

Permalink
forcing deprecation of useAccessibilityTree on observe (#445)
Browse files Browse the repository at this point in the history
* forcing deprecation of useAccessibilityTree on observe

* added changeset
  • Loading branch information
miguelg719 authored Jan 30, 2025
1 parent 1032d7d commit 5bc514f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rude-moles-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Adding back useAccessibilityTree param to observe with a deprecation warning/error indicating to use onlyVisible instead
16 changes: 16 additions & 0 deletions lib/StagehandPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,24 @@ export class StagehandPage {
domSettleTimeoutMs,
returnAction = false,
onlyVisible = false,
useAccessibilityTree,
} = options;

if (useAccessibilityTree !== undefined) {
this.stagehand.log({
category: "deprecation",
message:
"useAccessibilityTree is deprecated.\n" +
" To use accessibility tree as context:\n" +
" 1. Set onlyVisible to false (default)\n" +
" 2. Don't declare useAccessibilityTree",
level: 1,
});
throw new Error(
"useAccessibilityTree is deprecated. Use onlyVisible instead.",
);
}

if (typeof useVision !== "undefined") {
this.stagehand.log({
category: "deprecation",
Expand Down
3 changes: 2 additions & 1 deletion types/stagehand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ export interface ObserveOptions {
domSettleTimeoutMs?: number;
returnAction?: boolean;
onlyVisible?: boolean;
/** @deprecated `useAccessibilityTree` is now deprecated. Use `onlyVisible` instead. */
useAccessibilityTree?: boolean;
}

export interface ObserveResult {
selector: string;
description: string;
backendNodeId?: number;
//TODO: review name
method?: string;
arguments?: string[];
}

0 comments on commit 5bc514f

Please sign in to comment.