Skip to content

Commit 8d8d9f9

Browse files
authored
fix: seeCssPropertiesOnElements failed when font-weight is a number (#4026)
1 parent a23688d commit 8d8d9f9

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

Diff for: lib/helper/Playwright.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,9 @@ class Playwright extends Helper {
21232123
let chunked = chunkArray(props, values.length);
21242124
chunked = chunked.filter((val) => {
21252125
for (let i = 0; i < val.length; ++i) {
2126-
if (val[i] !== values[i]) return false;
2126+
const _acutal = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(val[i], 10);
2127+
const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10);
2128+
if (_acutal !== _expected) return false;
21272129
}
21282130
return true;
21292131
});

Diff for: lib/helper/Puppeteer.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,9 @@ class Puppeteer extends Helper {
17841784
let chunked = chunkArray(props, values.length);
17851785
chunked = chunked.filter((val) => {
17861786
for (let i = 0; i < val.length; ++i) {
1787-
if (val[i] !== values[i]) return false;
1787+
const _acutal = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(val[i], 10);
1788+
const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10);
1789+
if (_acutal !== _expected) return false;
17881790
}
17891791
return true;
17901792
});
@@ -1815,7 +1817,9 @@ class Puppeteer extends Helper {
18151817
let chunked = chunkArray(attrs, values.length);
18161818
chunked = chunked.filter((val) => {
18171819
for (let i = 0; i < val.length; ++i) {
1818-
if (val[i] !== values[i]) return false;
1820+
const _acutal = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(val[i], 10);
1821+
const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10);
1822+
if (_acutal !== _expected) return false;
18191823
}
18201824
return true;
18211825
});

Diff for: lib/helper/WebDriver.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,9 @@ class WebDriver extends Helper {
15081508
let chunked = chunkArray(props, values.length);
15091509
chunked = chunked.filter((val) => {
15101510
for (let i = 0; i < val.length; ++i) {
1511-
if (val[i] !== values[i]) return false;
1511+
const _acutal = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(val[i], 10);
1512+
const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10);
1513+
if (_acutal !== _expected) return false;
15121514
}
15131515
return true;
15141516
});
@@ -1535,7 +1537,9 @@ class WebDriver extends Helper {
15351537
let chunked = chunkArray(attrs, values.length);
15361538
chunked = chunked.filter((val) => {
15371539
for (let i = 0; i < val.length; ++i) {
1538-
if (val[i] !== values[i]) return false;
1540+
const _acutal = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(val[i], 10);
1541+
const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10);
1542+
if (_acutal !== _expected) return false;
15391543
}
15401544
return true;
15411545
});

Diff for: test/data/app/view/info.php

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
.span {
88
height: 15px;
99
}
10+
h4 {
11+
font-weight: 300;
12+
}
1013
</style>
1114
<body>
1215

@@ -23,6 +26,7 @@
2326
<div class="notice"><?php if (isset($notice)) echo $notice; ?></div>
2427

2528
<h3>Don't do that at home!</h3>
29+
<h4>Check font-weight!</h4>
2630

2731
<p>Is that interesting?</p>
2832

Diff for: test/helper/webapi.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1369,8 +1369,8 @@ module.exports.tests = function () {
13691369

13701370
try {
13711371
await I.amOnPage('/info');
1372-
await I.seeCssPropertiesOnElements('h3', {
1373-
'font-weight': 'bold',
1372+
await I.seeCssPropertiesOnElements('h4', {
1373+
'font-weight': 300,
13741374
});
13751375
await I.seeCssPropertiesOnElements('h3', {
13761376
'font-weight': 'bold',

0 commit comments

Comments
 (0)