File tree 3 files changed +17
-2
lines changed
3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -2168,7 +2168,8 @@ class Playwright extends Helper {
2168
2168
let chunked = chunkArray ( attrs , values . length ) ;
2169
2169
chunked = chunked . filter ( ( val ) => {
2170
2170
for ( let i = 0 ; i < val . length ; ++ i ) {
2171
- if ( ! val [ i ] . includes ( values [ i ] ) ) return false ;
2171
+ // if the attribute doesn't exist, returns false as well
2172
+ if ( ! val [ i ] || ! val [ i ] . includes ( values [ i ] ) ) return false ;
2172
2173
}
2173
2174
return true ;
2174
2175
} ) ;
Original file line number Diff line number Diff line change @@ -1823,7 +1823,8 @@ class Puppeteer extends Helper {
1823
1823
for ( let i = 0 ; i < val . length ; ++ i ) {
1824
1824
const _actual = Number . isNaN ( val [ i ] ) || ( typeof values [ i ] ) === 'string' ? val [ i ] : Number . parseInt ( values [ i ] , 10 ) ;
1825
1825
const _expected = Number . isNaN ( values [ i ] ) || ( typeof values [ i ] ) === 'string' ? values [ i ] : Number . parseInt ( values [ i ] , 10 ) ;
1826
- if ( ! _actual . includes ( _expected ) ) return false ;
1826
+ // if the attribute doesn't exist, returns false as well
1827
+ if ( ! _actual || ! _actual . includes ( _expected ) ) return false ;
1827
1828
}
1828
1829
return true ;
1829
1830
} ) ;
Original file line number Diff line number Diff line change @@ -1374,6 +1374,19 @@ module.exports.tests = function () {
1374
1374
e . message . should . include ( 'all elements (a) to have attributes {"qa-id":"test","href":"/info"}' ) ;
1375
1375
}
1376
1376
} ) ;
1377
+
1378
+ it ( 'should return error when using non existing attribute' , async function ( ) {
1379
+ if ( isHelper ( 'TestCafe' ) || isHelper ( 'WebDriver' ) ) this . skip ( ) ;
1380
+
1381
+ try {
1382
+ await I . amOnPage ( 'https://github.com/codeceptjs/CodeceptJS/' ) ;
1383
+ await I . seeAttributesOnElements ( { css : 'a[href="/team"]' } , {
1384
+ disable : true ,
1385
+ } ) ;
1386
+ } catch ( e ) {
1387
+ e . message . should . include ( 'expected all elements ({css: a[href="/team"]}) to have attributes {"disable":true} "0" to equal "1"' ) ;
1388
+ }
1389
+ } ) ;
1377
1390
} ) ;
1378
1391
1379
1392
describe ( '#seeCssPropertiesOnElements' , ( ) => {
You can’t perform that action at this time.
0 commit comments