I'm not sure how to ask this question correct since my understanding of the DOM is lacking.
What I'm trying to do is to catch any click event on any given DOM element. I then want to save the element type as well as the complete reference to element in a Database. But I'm not sure this is at all possible?
What i want to achieve is to save a hole interaction with a web app, in a way so you can later replay every action performed on the site, in a given session.
I have tried different approaches like getting the X and Y position of the clicked element, and later on trigger a click on those x-y coordinates, but theres several problems with this approach. I've also tried to traverse the Dom backwards until i reach the body tag, to build a unike selecter, but this also have it's shortcomings.. The best solution i can think of would be to save what ever $(this) contains.
If click events are the only thing you want to track, you probably want to add click event handlers to every clickable element on the page.
This would require starting at the <body> and walking the DOM, adding handlers as you go.
At the same time, I'd add a new data-xpath attribute to each element containing an XPath selector so you can use it in your handler to note the element being clicked, and so replay the user's interaction.
See http://www.w3schools.com/xpath/xpath_intro.asp for an introduction to XPath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With