ebrehault / resurrectio

CasperJS test recorder Chrome extension
GNU General Public License v2.0
721 stars 106 forks source link

backspace / delete not captured #28

Open webpunk opened 8 years ago

webpunk commented 8 years ago

I am facing the following problem:

1) start recording on any web page with a text field. 2) enter "somethinK" in the text field. 3) user backspace to delete character "k" 4) enter "g" 5) stop recording & generate a casper.js test file

When executing this test "somethinKg" will be sent to the text field. Wouldn't it be better to simply use the "onchange" event (instead of the "onkeypress" event) to figure out what has to be send to the text field?

ebrehault commented 8 years ago

The onchange event will not work properly, as some events might be triggered while the user is typing, it might be useful to test features like autocompletion for instance. So we do need to record all the keypress events. What needs to be fixed is the way we get back the resulting text so backspace are properly processed.

webpunk commented 8 years ago

Okay. But keep in mind that this actually would require to process all kinds of keyboard input: backspace, delete, using left / right / text / mark text / unmark text / mouseclick in text / ...

kensoh commented 6 years ago

Thanks @ebrehault for making Resurrectio! We exchanged emails some time back when I just made the beta release of a tool base on Resurrectio. @webpunk adding on that I traced the code and found the cause. Resurrectio uses onkeypress event to detect key strokes.

However, backspace and tab will only be registered using other events such as keydown or keyup. As that functionality is not critical for my use case, for now I didn't proceed to add the new events as it might break existing onkeypress behavior. onkeypress is the best approach although it does not cover edge cases such as backspace/tab.

UPDATE - wanted to add that I post the comment not for purpose of expecting action because I know that the repo is not actively maintained now. But want to add troubleshooting notes for references.