From cc46f345c0a1dc0af4abae7e207833df17da50e7 Mon Sep 17 00:00:00 2001 From: Paul Klein Date: Sat, 21 Dec 2024 15:58:28 -0800 Subject: [PATCH] Only startDomDebug if it's enabled (#325) * Only startDomDebug if it's enabled * changeset --------- Co-authored-by: Anirudh Kamath --- .changeset/tall-pots-share.md | 5 +++ lib/StagehandPage.ts | 60 ++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 .changeset/tall-pots-share.md diff --git a/.changeset/tall-pots-share.md b/.changeset/tall-pots-share.md new file mode 100644 index 00000000..355fc3ee --- /dev/null +++ b/.changeset/tall-pots-share.md @@ -0,0 +1,5 @@ +--- +"@browserbasehq/stagehand": patch +--- + +only start domdebug if enabled diff --git a/lib/StagehandPage.ts b/lib/StagehandPage.ts index ad75fcab..ece5494f 100644 --- a/lib/StagehandPage.ts +++ b/lib/StagehandPage.ts @@ -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", + }, }, - }, - }); + }); + } } }