Skip to content

Commit

Permalink
Only startDomDebug if it's enabled (#325)
Browse files Browse the repository at this point in the history
* Only startDomDebug if it's enabled

* changeset

---------

Co-authored-by: Anirudh Kamath <[email protected]>
  • Loading branch information
pkiv and kamath authored Dec 21, 2024
1 parent 6c831de commit cc46f34
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-pots-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

only start domdebug if enabled
60 changes: 31 additions & 29 deletions lib/StagehandPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,36 +110,38 @@ export class StagehandPage {
}

public async startDomDebug() {
try {
await this.page
.evaluate(() => {
if (typeof window.debugDom === "function") {
window.debugDom();
} else {
this.stagehand.log({
category: "dom",
message: "debugDom is not defined",
level: 1,
});
}
})
.catch(() => {});
} catch (e) {
this.stagehand.log({
category: "dom",
message: "Error in startDomDebug",
level: 1,
auxiliary: {
error: {
value: e.message,
type: "string",
},
trace: {
value: e.stack,
type: "string",
if (this.stagehand.debugDom) {
try {
await this.page
.evaluate(() => {
if (typeof window.debugDom === "function") {
window.debugDom();
} else {
this.stagehand.log({
category: "dom",
message: "debugDom is not defined",
level: 1,
});
}
})
.catch(() => {});
} catch (e) {
this.stagehand.log({
category: "dom",
message: "Error in startDomDebug",
level: 1,
auxiliary: {
error: {
value: e.message,
type: "string",
},
trace: {
value: e.stack,
type: "string",
},
},
},
});
});
}
}
}

Expand Down

0 comments on commit cc46f34

Please sign in to comment.