From b616ec57b37e1ac8692b05f16e9496642ea069ce Mon Sep 17 00:00:00 2001 From: KobeNguyenT <7845001+kobenguyent@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:40:32 +0000 Subject: [PATCH] fix: seeCssPropertiesOnElements failed when font-wieght is a numberfix: seeCssPropertiesOnElements failed when font-wieght is a number --- lib/helper/Playwright.js | 4 +++- lib/helper/Puppeteer.js | 4 +++- lib/helper/WebDriver.js | 4 +++- test/data/app/view/info.php | 4 ++++ test/helper/webapi.js | 4 ++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 2c76f9065..9a3792d2b 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -2116,7 +2116,9 @@ class Playwright extends Helper { let chunked = chunkArray(props, values.length); chunked = chunked.filter((val) => { for (let i = 0; i < val.length; ++i) { - if (val[i] !== values[i]) return false; + const _acutal = 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); + if (_acutal !== _expected) return false; } return true; }); diff --git a/lib/helper/Puppeteer.js b/lib/helper/Puppeteer.js index 76f1ac2b5..a91c675e5 100644 --- a/lib/helper/Puppeteer.js +++ b/lib/helper/Puppeteer.js @@ -1815,7 +1815,9 @@ class Puppeteer extends Helper { let chunked = chunkArray(attrs, values.length); chunked = chunked.filter((val) => { for (let i = 0; i < val.length; ++i) { - if (val[i] !== values[i]) return false; + const _acutal = 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); + if (_acutal !== _expected) return false; } return true; }); diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index a6f701a56..021097f0b 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1535,7 +1535,9 @@ class WebDriver extends Helper { let chunked = chunkArray(attrs, values.length); chunked = chunked.filter((val) => { for (let i = 0; i < val.length; ++i) { - if (val[i] !== values[i]) return false; + const _acutal = 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); + if (_acutal !== _expected) return false; } return true; }); diff --git a/test/data/app/view/info.php b/test/data/app/view/info.php index 6f0154fbd..e08a996b9 100755 --- a/test/data/app/view/info.php +++ b/test/data/app/view/info.php @@ -7,6 +7,9 @@ .span { height: 15px; } + h4 { + font-weight: 300; + }
@@ -23,6 +26,7 @@Is that interesting?
diff --git a/test/helper/webapi.js b/test/helper/webapi.js index c55e11637..eb4d6b7b1 100644 --- a/test/helper/webapi.js +++ b/test/helper/webapi.js @@ -1369,8 +1369,8 @@ module.exports.tests = function () { try { await I.amOnPage('/info'); - await I.seeCssPropertiesOnElements('h3', { - 'font-weight': 'bold', + await I.seeCssPropertiesOnElements('h4', { + 'font-weight': 300, }); await I.seeCssPropertiesOnElements('h3', { 'font-weight': 'bold',