Skip to content

Commit 0d51f89

Browse files
Copilotkobenguyent
andcommitted
Changes before error encountered
Co-authored-by: kobenguyent <[email protected]>
1 parent 10f97e6 commit 0d51f89

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

lib/helper/Playwright.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,34 +2802,31 @@ class Playwright extends Helper {
28022802
}
28032803
}
28042804

2805-
// Use two complementary strategies that both respect the full timeout:
2806-
// Strategy 1: waitForFunction checks body text AND title text
2807-
// Strategy 2: native Playwright locator for visible elements
2808-
return Promise.race([
2809-
// Strategy 1: Check both body text and title text (fixes original bug)
2810-
contextObject.waitForFunction(
2805+
// Simple approach: use waitForFunction that checks all text sources
2806+
// This handles both body text and title text in one strategy
2807+
return contextObject
2808+
.waitForFunction(
28112809
text => {
28122810
// Check body text (original behavior)
28132811
if (document.body && document.body.innerText.indexOf(text) > -1) {
28142812
return true
28152813
}
2816-
// Also check document title (new addition to fix title text detection)
2814+
// Check document title (fixes the TestEd in title issue)
28172815
if (document.title && document.title.indexOf(text) > -1) {
28182816
return true
28192817
}
2818+
// Also check document.documentElement.innerText which includes title
2819+
if (document.documentElement && document.documentElement.innerText.indexOf(text) > -1) {
2820+
return true
2821+
}
28202822
return false
28212823
},
28222824
text,
28232825
{ timeout: waitTimeout },
2824-
),
2825-
// Strategy 2: Use Playwright's native text locator for visible elements
2826-
contextObject
2827-
.locator(`:has-text(${JSON.stringify(text)})`)
2828-
.first()
2829-
.waitFor({ timeout: waitTimeout, state: 'visible' }),
2830-
]).catch(err => {
2831-
throw new Error(errorMessage)
2832-
})
2826+
)
2827+
.catch(err => {
2828+
throw new Error(errorMessage)
2829+
})
28332830
}
28342831

28352832
/**

0 commit comments

Comments
 (0)