@@ -275,6 +275,7 @@ export class InjectedScript {
275275 const result = this . querySelectorAll ( selector , root ) ;
276276 if ( strict && result . length > 1 )
277277 throw this . strictModeViolationError ( selector , result ) ;
278+ this . checkDeprecatedSelectorUsage ( selector , result ) ;
278279 return result [ 0 ] ;
279280 }
280281
@@ -1228,28 +1229,44 @@ export class InjectedScript {
12281229 return oneLine ( `<${ element . nodeName . toLowerCase ( ) } ${ attrText } >${ trimStringWithEllipsis ( text , 50 ) } </${ element . nodeName . toLowerCase ( ) } >` ) ;
12291230 }
12301231
1231- strictModeViolationError ( selector : ParsedSelector , matches : Element [ ] ) : Error {
1232+ private _generateSelectors ( elements : Element [ ] ) {
12321233 this . _evaluator . begin ( ) ;
12331234 beginAriaCaches ( ) ;
12341235 beginDOMCaches ( ) ;
12351236 try {
12361237 // Firefox is slow to access DOM bindings in the utility world, making it very expensive to generate a lot of selectors.
12371238 const maxElements = this . _isUtilityWorld && this . _browserName === 'firefox' ? 2 : 10 ;
1238- const infos = matches . slice ( 0 , maxElements ) . map ( m => ( {
1239+ const infos = elements . slice ( 0 , maxElements ) . map ( m => ( {
12391240 preview : this . previewNode ( m ) ,
12401241 selector : this . generateSelectorSimple ( m ) ,
12411242 } ) ) ;
1242- const lines = infos . map ( ( info , i ) => `\n ${ i + 1 } ) ${ info . preview } aka ${ asLocator ( this . _sdkLanguage , info . selector ) } ` ) ;
1243- if ( infos . length < matches . length )
1244- lines . push ( '\n ...' ) ;
1245- return this . createStacklessError ( `strict mode violation: ${ asLocator ( this . _sdkLanguage , stringifySelector ( selector ) ) } resolved to ${ matches . length } elements:${ lines . join ( '' ) } \n` ) ;
1243+ return infos . map ( ( info , i ) => `${ i + 1 } ) ${ info . preview } aka ${ asLocator ( this . _sdkLanguage , info . selector ) } ` ) ;
12461244 } finally {
12471245 endDOMCaches ( ) ;
12481246 endAriaCaches ( ) ;
12491247 this . _evaluator . end ( ) ;
12501248 }
12511249 }
12521250
1251+ strictModeViolationError ( selector : ParsedSelector , matches : Element [ ] ) : Error {
1252+ const lines = this . _generateSelectors ( matches ) . map ( line => `\n ` + line ) ;
1253+ if ( lines . length < matches . length )
1254+ lines . push ( '\n ...' ) ;
1255+ return this . createStacklessError ( `strict mode violation: ${ asLocator ( this . _sdkLanguage , stringifySelector ( selector ) ) } resolved to ${ matches . length } elements:${ lines . join ( '' ) } \n` ) ;
1256+ }
1257+
1258+ checkDeprecatedSelectorUsage ( selector : ParsedSelector , matches : Element [ ] ) {
1259+ if ( ! matches . length )
1260+ return ;
1261+ const deperecated = selector . parts . find ( part => part . name === '_react' || part . name === '_vue' ) ;
1262+ if ( ! deperecated )
1263+ return ;
1264+ const lines = this . _generateSelectors ( matches ) . map ( line => `\n ` + line ) ;
1265+ if ( lines . length < matches . length )
1266+ lines . push ( '\n ...' ) ;
1267+ throw this . createStacklessError ( `"${ deperecated . name } " selector is not supported: ${ asLocator ( this . _sdkLanguage , stringifySelector ( selector ) ) } resolved to ${ matches . length } element${ matches . length === 1 ? '' : 's' } :${ lines . join ( '' ) } \n` ) ;
1268+ }
1269+
12531270 createStacklessError ( message : string ) : Error {
12541271 if ( this . _browserName === 'firefox' ) {
12551272 const error = new Error ( 'Error: ' + message ) ;
0 commit comments