Skip to content

Commit 73f74bb

Browse files
authored
fix: seeAttributesOnElements check condition (#4029)
1 parent 3c0bbb1 commit 73f74bb

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

lib/helper/Playwright.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,7 @@ class Playwright extends Helper {
21542154
let chunked = chunkArray(attrs, values.length);
21552155
chunked = chunked.filter((val) => {
21562156
for (let i = 0; i < val.length; ++i) {
2157-
if (val[i] !== values[i]) return false;
2157+
if (!val[i].includes(values[i])) return false;
21582158
}
21592159
return true;
21602160
});

lib/helper/Puppeteer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,9 +1817,9 @@ class Puppeteer extends Helper {
18171817
let chunked = chunkArray(attrs, values.length);
18181818
chunked = chunked.filter((val) => {
18191819
for (let i = 0; i < val.length; ++i) {
1820-
const _acutal = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(val[i], 10);
1820+
const _actual = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(values[i], 10);
18211821
const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10);
1822-
if (_acutal !== _expected) return false;
1822+
if (!_actual.includes(_expected)) return false;
18231823
}
18241824
return true;
18251825
});

test/helper/webapi.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,19 @@ module.exports.tests = function () {
13401340
}
13411341
});
13421342

1343+
it('should check href with slash', async function () {
1344+
if (isHelper('TestCafe') || isHelper('WebDriver')) this.skip();
1345+
1346+
try {
1347+
await I.amOnPage('https://github.com/codeceptjs/CodeceptJS/');
1348+
await I.seeAttributesOnElements({ css: 'a[href="/team"]' }, {
1349+
href: '/team',
1350+
});
1351+
} catch (e) {
1352+
e.message.should.include('all elements (a[href="/team"]) to have attributes {"href":"/team"}');
1353+
}
1354+
});
1355+
13431356
it('should check attributes values for several elements', async function () {
13441357
if (isHelper('TestCafe')) this.skip();
13451358

0 commit comments

Comments
 (0)