@@ -650,12 +650,13 @@ class JsonRecordActionTool implements RecorderTool {
650650 return ;
651651
652652 const checkbox = asCheckbox ( element ) ;
653- const { ariaSnapshot, selector } = this . _ariaSnapshot ( element ) ;
653+ const { ariaSnapshot, selector, ref } = this . _ariaSnapshot ( element ) ;
654654 if ( checkbox && event . detail === 1 ) {
655655 // Interestingly, inputElement.checked is reversed inside this event handler.
656656 this . _recorder . recordAction ( {
657657 name : checkbox . checked ? 'check' : 'uncheck' ,
658658 selector,
659+ ref,
659660 signals : [ ] ,
660661 ariaSnapshot,
661662 } ) ;
@@ -665,6 +666,7 @@ class JsonRecordActionTool implements RecorderTool {
665666 this . _recorder . recordAction ( {
666667 name : 'click' ,
667668 selector,
669+ ref,
668670 ariaSnapshot,
669671 position : positionForEvent ( event ) ,
670672 signals : [ ] ,
@@ -681,27 +683,29 @@ class JsonRecordActionTool implements RecorderTool {
681683 if ( this . _shouldIgnoreMouseEvent ( event ) )
682684 return ;
683685
684- const { ariaSnapshot, selector } = this . _ariaSnapshot ( element ) ;
686+ const { ariaSnapshot, selector, ref } = this . _ariaSnapshot ( element ) ;
685687 this . _recorder . recordAction ( {
686688 name : 'click' ,
687689 selector,
690+ ref,
688691 ariaSnapshot,
689692 position : positionForEvent ( event ) ,
690693 signals : [ ] ,
691694 button : buttonForEvent ( event ) ,
692695 modifiers : modifiersForEvent ( event ) ,
693- clickCount : event . detail
696+ clickCount : event . detail ,
694697 } ) ;
695698 }
696699
697700 onInput ( event : Event ) {
698701 const element = this . _recorder . deepEventTarget ( event ) ;
699702
700- const { ariaSnapshot, selector } = this . _ariaSnapshot ( element ) ;
703+ const { ariaSnapshot, selector, ref } = this . _ariaSnapshot ( element ) ;
701704 if ( isRangeInput ( element ) ) {
702705 this . _recorder . recordAction ( {
703706 name : 'fill' ,
704707 selector,
708+ ref,
705709 ariaSnapshot,
706710 signals : [ ] ,
707711 text : element . value ,
@@ -717,6 +721,7 @@ class JsonRecordActionTool implements RecorderTool {
717721
718722 this . _recorder . recordAction ( {
719723 name : 'fill' ,
724+ ref,
720725 selector,
721726 ariaSnapshot,
722727 signals : [ ] ,
@@ -730,6 +735,7 @@ class JsonRecordActionTool implements RecorderTool {
730735 this . _recorder . recordAction ( {
731736 name : 'select' ,
732737 selector,
738+ ref,
733739 ariaSnapshot,
734740 options : [ ...selectElement . selectedOptions ] . map ( option => option . value ) ,
735741 signals : [ ]
@@ -743,7 +749,7 @@ class JsonRecordActionTool implements RecorderTool {
743749 return ;
744750
745751 const element = this . _recorder . deepEventTarget ( event ) ;
746- const { ariaSnapshot, selector } = this . _ariaSnapshot ( element ) ;
752+ const { ariaSnapshot, selector, ref } = this . _ariaSnapshot ( element ) ;
747753
748754 // Similarly to click, trigger checkbox on key event, not input.
749755 if ( event . key === ' ' ) {
@@ -752,6 +758,7 @@ class JsonRecordActionTool implements RecorderTool {
752758 this . _recorder . recordAction ( {
753759 name : checkbox . checked ? 'uncheck' : 'check' ,
754760 selector,
761+ ref,
755762 ariaSnapshot,
756763 signals : [ ] ,
757764 } ) ;
@@ -762,6 +769,7 @@ class JsonRecordActionTool implements RecorderTool {
762769 this . _recorder . recordAction ( {
763770 name : 'press' ,
764771 selector,
772+ ref,
765773 ariaSnapshot,
766774 signals : [ ] ,
767775 key : event . key ,
@@ -819,12 +827,12 @@ class JsonRecordActionTool implements RecorderTool {
819827 return false ;
820828 }
821829
822- private _ariaSnapshot ( element : HTMLElement ) : { ariaSnapshot : string , selector : string } ;
823- private _ariaSnapshot ( element : HTMLElement | undefined ) : { ariaSnapshot : string , selector ?: string } {
830+ private _ariaSnapshot ( element : HTMLElement ) : { ariaSnapshot : string , selector : string , ref ?: string } ;
831+ private _ariaSnapshot ( element : HTMLElement | undefined ) : { ariaSnapshot : string , selector ?: string , ref ?: string } {
824832 const { ariaSnapshot, refs } = this . _recorder . injectedScript . ariaSnapshotForRecorder ( ) ;
825833 const ref = element ? refs . get ( element ) : undefined ;
826- const selector = ref ? `aria-ref= ${ ref } ` : undefined ;
827- return { ariaSnapshot, selector } ;
834+ const elementInfo = element ? this . _recorder . injectedScript . generateSelector ( element , { testIdAttributeName : this . _recorder . state . testIdAttributeName } ) : undefined ;
835+ return { ariaSnapshot, selector : elementInfo ?. selector , ref } ;
828836 }
829837}
830838
0 commit comments