Skip to content

Commit 037877f

Browse files
committed
Recorder: Add "\n" to input text on form-submit actions
1 parent 69b7bc2 commit 037877f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

seleniumbase/js_code/recorder_js.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,23 @@
354354
document.body.addEventListener('click', function (event) {
355355
// Do Nothing.
356356
});
357+
document.body.addEventListener('submit', function (event) {
358+
reset_if_recorder_undefined();
359+
if (sessionStorage.getItem('pause_recorder') === 'yes') return;
360+
const d_now = Date.now();
361+
ra_len = document.recorded_actions.length;
362+
if (ra_len > 0 &&
363+
document.recorded_actions[ra_len-1][0] === 'input' &&
364+
!document.recorded_actions[ra_len-1][2].endsWith('\n'))
365+
{
366+
selector = document.recorded_actions[ra_len-1][1];
367+
text = document.recorded_actions[ra_len-1][2] + '\n';
368+
document.recorded_actions.pop();
369+
document.recorded_actions.push(['input', selector, text, d_now]);
370+
json_rec_act = JSON.stringify(document.recorded_actions);
371+
sessionStorage.setItem('recorded_actions', json_rec_act);
372+
}
373+
});
357374
document.body.addEventListener('formdata', function (event) {
358375
reset_if_recorder_undefined();
359376
if (sessionStorage.getItem('pause_recorder') === 'yes') return;

0 commit comments

Comments
 (0)