@@ -252,6 +252,12 @@ class="profile-picture" />
252252 <!-- Elements for Event Testing -->
253253 <div class =" section" >
254254 <h2 >Event Testing</h2 >
255+ <div id =" focus-display" data-testid =" focus-display" class =" p-2 bg-blue-50 border text-sm mb-2" >No element focused yet</div >
256+ <div id =" hover-display" data-testid =" hover-display" class =" p-2 bg-green-50 border text-sm mb-2" >No element hovered yet</div >
257+ <div id =" hover-target" data-testid =" hover-target" class =" p-4 border bg-blue-100 hover:bg-blue-200 transition-colors cursor-pointer mb-4" >
258+ Hover Target
259+ </div >
260+ <input id =" focus-target" data-testid =" focus-target" type =" text" class =" bg-white text-black p-2 border focus:border-blue-500 mb-4" placeholder =" Focus on me" />
255261 <button id =" event-button" data-testid =" event-button" >Click Me</button >
256262 <div id =" event-result" data-testid =" event-result" ></div >
257263 </div >
@@ -262,9 +268,7 @@ class="profile-picture" />
262268 <div data-testid =" scroll-target" style =" margin-top : 500px ;" >
263269 This element is far down the page for scroll testing
264270 </div >
265- </div >
266-
267- <script >
271+ </div > <script >
268272 // Counter for click testing
269273 let clickCounter = 0 ;
270274
@@ -273,6 +277,22 @@ function incrementCounter() {
273277 document .querySelector (' [data-testid="click-counter"]' ).textContent = clickCounter;
274278 }
275279
280+ // Focus tracking function
281+ function trackFocus (elementId ) {
282+ const focusDisplay = document .getElementById (' focus-display' );
283+ if (focusDisplay) {
284+ focusDisplay .textContent = ' Last focused: ' + elementId;
285+ }
286+ }
287+
288+ // Hover tracking function
289+ function trackHover (elementId ) {
290+ const hoverDisplay = document .getElementById (' hover-display' );
291+ if (hoverDisplay) {
292+ hoverDisplay .textContent = ' Last hovered: ' + elementId;
293+ }
294+ }
295+
276296 // Add some basic interactivity for testing
277297 document .addEventListener (' DOMContentLoaded' , function () {
278298 // Event button click handler
@@ -285,6 +305,40 @@ function incrementCounter() {
285305 });
286306 }
287307
308+ // Add focus tracking event listeners
309+ document .getElementById (' focus-target' ).addEventListener (' focus' , function () {
310+ trackFocus (' focus-target' );
311+ });
312+ document .getElementById (' username' ).addEventListener (' focus' , function () {
313+ trackFocus (' username' );
314+ });
315+ document .getElementById (' password' ).addEventListener (' focus' , function () {
316+ trackFocus (' password' );
317+ });
318+ document .getElementById (' search' ).addEventListener (' focus' , function () {
319+ trackFocus (' search' );
320+ });
321+ document .getElementById (' comments' ).addEventListener (' focus' , function () {
322+ trackFocus (' comments' );
323+ });
324+
325+ // Hover tracking
326+ const hoverTarget = document .getElementById (' hover-target' );
327+ if (hoverTarget) {
328+ [' mouseenter' , ' mouseover' , ' pointerenter' ].forEach (event => {
329+ hoverTarget .addEventListener (event , function () {
330+ trackHover (' hover-target' );
331+ });
332+ });
333+ }
334+
335+ // Add global hover detection for Playwright compatibility
336+ document .addEventListener (' mousemove' , function (e ) {
337+ if (e .target .id === ' hover-target' ) {
338+ trackHover (' hover-target' );
339+ }
340+ });
341+
288342 // Make forms more interactive
289343 const usernameInput = document .getElementById (' username' );
290344 if (usernameInput) {
0 commit comments