From 3d12f1f279ee827afc1c5ac965f6b15b4dfcc07a Mon Sep 17 00:00:00 2001 From: Andy Fleming Date: Thu, 26 Jul 2018 16:24:04 -0700 Subject: [PATCH] feat(FrameManager): improve waiting for selector to be hidden error message (#2911) Fixes #2854 --- lib/FrameManager.js | 3 ++- test/frame.spec.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/FrameManager.js b/lib/FrameManager.js index 3a79b763..3ff08b8d 100644 --- a/lib/FrameManager.js +++ b/lib/FrameManager.js @@ -728,7 +728,8 @@ class Frame { const waitForHidden = !!options.hidden; const polling = waitForVisible || waitForHidden ? 'raf' : 'mutation'; const timeout = helper.isNumber(options.timeout) ? options.timeout : 30000; - return new WaitTask(this, predicate, `${isXPath ? 'XPath' : 'selector'} "${selectorOrXPath}"`, polling, timeout, selectorOrXPath, isXPath, waitForVisible, waitForHidden).promise; + const title = `${isXPath ? 'XPath' : 'selector'} "${selectorOrXPath}"${waitForHidden ? ' to be hidden' : ''}`; + return new WaitTask(this, predicate, title, polling, timeout, selectorOrXPath, isXPath, waitForVisible, waitForHidden).promise; /** * @param {string} selectorOrXPath diff --git a/test/frame.spec.js b/test/frame.spec.js index 4b05c6a1..46d925d5 100644 --- a/test/frame.spec.js +++ b/test/frame.spec.js @@ -318,6 +318,13 @@ module.exports.addTests = function({testRunner, expect}) { expect(error).toBeTruthy(); expect(error.message).toContain('waiting for selector "div" failed: timeout'); }); + it('should have an error message specifically for awaiting an element to be hidden', async({page, server}) => { + await page.setContent(`
`); + let error = null; + await page.waitForSelector('div', {hidden: true, timeout: 10}).catch(e => error = e); + expect(error).toBeTruthy(); + expect(error.message).toContain('waiting for selector "div" to be hidden failed: timeout'); + }); it('should respond to node attribute mutation', async({page, server}) => { let divFound = false;