diff --git a/lib/helper/Puppeteer.js b/lib/helper/Puppeteer.js index 25fd1d8e0..0b8bf2a5c 100644 --- a/lib/helper/Puppeteer.js +++ b/lib/helper/Puppeteer.js @@ -3216,14 +3216,18 @@ async function proceedSee(assertType, text, context, strict = false) { let description let allText if (!context) { - let el = await this.context + if (this.withinLocator) { + let el = await this.context - if (el && !el.getProperty) { - // Fallback to body - el = await this.context.$('body') - } + if (el && !el.getProperty) { + el = await this.context.$('body') + } - allText = [await el.evaluate(node => node.innerText)] + allText = [await el.evaluate(node => node.innerText)] + } else { + const ctx = await this._getContext() + allText = [await ctx.evaluate(() => document.body.innerText)] + } description = 'web application' } else { const locator = new Locator(context, 'css') diff --git a/test/acceptance/config_test.js b/test/acceptance/config_test.js index 6436de496..f92c1b7a3 100644 --- a/test/acceptance/config_test.js +++ b/test/acceptance/config_test.js @@ -43,5 +43,5 @@ Scenario('change config 6 @WebDriverIO @Puppeteer @Playwright @Obscura', ({ I }) Scenario('simple page test @WebDriverIO @Puppeteer @Playwright @Obscura', ({ I }) => { I.amOnPage('https://example.com') - I.see('Example Domain') + I.seeInTitle('Example Domain') })