diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index a2a8645f0..96decd2f8 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -2169,6 +2169,8 @@ class Playwright extends Helper { let chunked = chunkArray(attrs, values.length); chunked = chunked.filter((val) => { for (let i = 0; i < val.length; ++i) { + // the attribute could be a boolean + if (typeof val[i] === 'boolean') return val[i] === values[i]; // if the attribute doesn't exist, returns false as well if (!val[i] || !val[i].includes(values[i])) return false; } diff --git a/lib/helper/Puppeteer.js b/lib/helper/Puppeteer.js index bbc187acb..0880222b4 100644 --- a/lib/helper/Puppeteer.js +++ b/lib/helper/Puppeteer.js @@ -1825,6 +1825,8 @@ class Puppeteer extends Helper { for (let i = 0; i < val.length; ++i) { const _actual = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(values[i], 10); const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10); + // the attribute could be a boolean + if (typeof _actual === 'boolean') return _actual === _expected; // if the attribute doesn't exist, returns false as well if (!_actual || !_actual.includes(_expected)) return false; } diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 0102fb823..f0ed73ee3 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1612,6 +1612,8 @@ class WebDriver extends Helper { for (let i = 0; i < val.length; ++i) { const _actual = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(val[i], 10); const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10); + // the attribute could be a boolean + if (typeof _actual === 'boolean') return _actual === _expected; if (_actual !== _expected) return false; } return true; diff --git a/test/data/app/view/index.php b/test/data/app/view/index.php index 08ccb7c0f..c25c9565e 100755 --- a/test/data/app/view/index.php +++ b/test/data/app/view/index.php @@ -25,6 +25,10 @@ Spinner +
+ Hidden input +
+ A wise man said: "debug!" diff --git a/test/helper/webapi.js b/test/helper/webapi.js index 73d2b69f0..b8a1d2010 100644 --- a/test/helper/webapi.js +++ b/test/helper/webapi.js @@ -1319,8 +1319,8 @@ module.exports.tests = function () { }); describe('#seeAttributesOnElements', () => { - it.skip('should check attributes values for given element', async function () { - if (isHelper('TestCafe')) this.skip(); + it('should check attributes values for given element', async function () { + if (isHelper('TestCafe') || isHelper('WebDriver')) this.skip(); try { await I.amOnPage('/info'); @@ -1387,6 +1387,19 @@ module.exports.tests = function () { e.message.should.include('expected all elements ({css: a[href="/team"]}) to have attributes {"disable":true} "0" to equal "1"'); } }); + + it('should verify the boolean attribute', async function () { + if (isHelper('TestCafe') || isHelper('WebDriver')) this.skip(); + + try { + await I.amOnPage('/'); + await I.seeAttributesOnElements('input', { + disabled: true, + }); + } catch (e) { + e.message.should.include('expected all elements (input) to have attributes {"disabled":true} "0" to equal "1"'); + } + }); }); describe('#seeCssPropertiesOnElements', () => {