@@ -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
@@ -3444,6 +3431,7 @@ async function proceedClick(locator, context = null, options = {}) {
34443431 }
34453432
34463433 await highlightActiveElement . call ( this , els [ 0 ] )
3434+ if ( store . debugMode ) this . debugSection ( 'Clicked' , await elToString ( els [ 0 ] , 1 ) )
34473435
34483436 /*
34493437 using the force true options itself but instead dispatching a click
@@ -3877,11 +3865,22 @@ async function saveTraceForContext(context, name) {
38773865}
38783866
38793867async function highlightActiveElement ( element ) {
3880- if ( this . options . highlightElement && global . debugMode ) {
3868+ if ( ( this . options . highlightElement || store . onPause ) && store . debugMode ) {
38813869 await element . evaluate ( el => {
38823870 const prevStyle = el . style . boxShadow
3883- el . style . boxShadow = '0px 0px 4px 3px rgba(255, 0, 0 , 0.7)'
3871+ el . style . boxShadow = '0px 0px 4px 3px rgba(147, 51, 234 , 0.8)' // Bright purple that works on both dark/light modes
38843872 setTimeout ( ( ) => ( el . style . boxShadow = prevStyle ) , 2000 )
38853873 } )
38863874 }
38873875}
3876+
3877+ async function elToString ( el , numberOfElements ) {
3878+ const html = await el . evaluate ( node => node . outerHTML )
3879+ return (
3880+ html
3881+ . replace ( / \n / g, '' )
3882+ . replace ( / \s + / g, ' ' )
3883+ . substring ( 0 , 100 / numberOfElements )
3884+ . trim ( ) + '...'
3885+ )
3886+ }
0 commit comments