@@ -1255,28 +1255,14 @@ class Playwright extends Helper {
12551255
12561256 if ( store . debugMode ) {
12571257 const previewElements = els . slice ( 0 , 3 )
1258- let htmls = await Promise . all (
1259- previewElements . map ( async el => {
1260- const html = await el . evaluate ( node => node . outerHTML )
1261- return (
1262- html
1263- . replace ( / \n / g, '' )
1264- . replace ( / \s + / g, ' ' )
1265- . substring ( 0 , 100 / previewElements . length )
1266- . trim ( ) + '...'
1267- )
1268- } ) ,
1269- )
1270- if ( els . length > 3 ) {
1271- htmls . push ( '...' )
1272- }
1273-
1258+ let htmls = await Promise . all ( previewElements . map ( el => elToString ( el , previewElements . length ) ) )
1259+ if ( els . length > 3 ) htmls . push ( '...' )
12741260 if ( els . length > 1 ) {
12751261 this . debugSection ( `Elements (${ els . length } )` , htmls . join ( '|' ) . trim ( ) )
12761262 } else if ( els . length === 1 ) {
12771263 this . debugSection ( 'Element' , htmls . join ( '|' ) . trim ( ) )
12781264 } else {
1279- this . debug ( ' No elements found' )
1265+ this . debug ( ` No elements found by ${ JSON . stringify ( locator ) . slice ( 0 , 50 ) } ....` )
12801266 }
12811267 }
12821268
@@ -1734,6 +1720,7 @@ class Playwright extends Helper {
17341720 const el = els [ 0 ]
17351721
17361722 await el . clear ( )
1723+ if ( store . debugMode ) this . debugSection ( 'Focused' , await elToString ( el , 1 ) )
17371724
17381725 await highlightActiveElement . call ( this , el )
17391726
@@ -3447,6 +3434,7 @@ async function proceedClick(locator, context = null, options = {}) {
34473434 }
34483435
34493436 await highlightActiveElement . call ( this , els [ 0 ] )
3437+ if ( store . debugMode ) this . debugSection ( 'Clicked' , await elToString ( els [ 0 ] , 1 ) )
34503438
34513439 /*
34523440 using the force true options itself but instead dispatching a click
@@ -3880,11 +3868,22 @@ async function saveTraceForContext(context, name) {
38803868}
38813869
38823870async function highlightActiveElement ( element ) {
3883- if ( this . options . highlightElement && global . debugMode ) {
3871+ if ( ( this . options . highlightElement || store . onPause ) && store . debugMode ) {
38843872 await element . evaluate ( el => {
38853873 const prevStyle = el . style . boxShadow
3886- el . style . boxShadow = '0px 0px 4px 3px rgba(255, 0, 0 , 0.7)'
3874+ el . style . boxShadow = '0px 0px 4px 3px rgba(147, 51, 234 , 0.8)' // Bright purple that works on both dark/light modes
38873875 setTimeout ( ( ) => ( el . style . boxShadow = prevStyle ) , 2000 )
38883876 } )
38893877 }
38903878}
3879+
3880+ async function elToString ( el , numberOfElements ) {
3881+ const html = await el . evaluate ( node => node . outerHTML )
3882+ return (
3883+ html
3884+ . replace ( / \n / g, '' )
3885+ . replace ( / \s + / g, ' ' )
3886+ . substring ( 0 , 100 / numberOfElements )
3887+ . trim ( ) + '...'
3888+ )
3889+ }
0 commit comments