segmentio / daydream

A chrome extension to record your actions into a nightmare or puppeteer script
https://open.segment.com
2.77k stars 174 forks source link

Support for additional input types. #58

Open Bored0ne opened 6 years ago

Bored0ne commented 6 years ago

This appears to only support standard "input" elements. Would it not be possible to bind to the value changed event for inputs to handle support for things like checkboxes or input buttons? I'm using this to test asp webforms and the default button is an and this isn't picking up their clicks. This could support the following list of types fairly easily. https://www.w3schools.com/tags/att_input_type.asp

MynockSpit commented 6 years ago

It currently does support button. That said if you pull this locally and install it as a developer package, you can change it to register clicks on everything. Something like this:

   start () {
     const typeableElements = document.querySelectorAll('input, textarea')
-    const clickableElements = document.querySelectorAll('a, button')

     for (let i = 0; i < typeableElements.length; i++) {
       typeableElements[i].addEventListener('keydown', this.handleKeydown)
     }

+    document.addEventListener('click', this.handleClick)
-    for (let i = 0; i < clickableElements.length; i++) {
-      clickableElements[i].addEventListener('click', this.handleClick)
-    }
   }
Bored0ne commented 5 years ago

Wow I'm just seeing this. Yes that would work way better. Do people not want this by default?

MynockSpit commented 5 years ago

Actually, it should probably be tweaked more. The current pattern doesn't support elements that were created after the recording started. Will have to play with it more.

Not sure about it being defaulted. 😕