From 6fed160e81cb0d4f0e6f02b9fd8973798dd26779 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 22 Jan 2024 09:38:26 +0100 Subject: [PATCH 1/3] fix: seeAttributesOnElements logic --- lib/helper/Playwright.js | 2 ++ lib/helper/Puppeteer.js | 2 ++ lib/helper/WebDriver.js | 2 ++ test/data/app/view/index.php | 4 ++++ test/helper/webapi.js | 17 +++++++++++++++-- 5 files changed, 25 insertions(+), 2 deletions(-) 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..daaaf7f42 100644 --- a/test/helper/webapi.js +++ b/test/helper/webapi.js @@ -1318,8 +1318,8 @@ module.exports.tests = function () { }); }); - describe('#seeAttributesOnElements', () => { - it.skip('should check attributes values for given element', async function () { + describe.only('#seeAttributesOnElements', () => { + it('should check attributes values for given element', async function () { if (isHelper('TestCafe')) this.skip(); try { @@ -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', () => { From e5e438607fc4ac5e3e47d9d0e3df5ae882e73c3e Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 22 Jan 2024 09:38:58 +0100 Subject: [PATCH 2/3] fix: seeAttributesOnElements logic --- test/helper/webapi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper/webapi.js b/test/helper/webapi.js index daaaf7f42..e462cf2df 100644 --- a/test/helper/webapi.js +++ b/test/helper/webapi.js @@ -1318,7 +1318,7 @@ module.exports.tests = function () { }); }); - describe.only('#seeAttributesOnElements', () => { + describe('#seeAttributesOnElements', () => { it('should check attributes values for given element', async function () { if (isHelper('TestCafe')) this.skip(); From 04c94d96cb2ed0fe921577d93bfed23a7f331b1f Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 22 Jan 2024 09:47:18 +0100 Subject: [PATCH 3/3] fix: seeAttributesOnElements logic --- test/helper/webapi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper/webapi.js b/test/helper/webapi.js index e462cf2df..b8a1d2010 100644 --- a/test/helper/webapi.js +++ b/test/helper/webapi.js @@ -1320,7 +1320,7 @@ module.exports.tests = function () { describe('#seeAttributesOnElements', () => { it('should check attributes values for given element', async function () { - if (isHelper('TestCafe')) this.skip(); + if (isHelper('TestCafe') || isHelper('WebDriver')) this.skip(); try { await I.amOnPage('/info');