better form submission in fill() by using events
Showing
1 changed file
with
6 additions
and
0 deletions
... | @@ -740,6 +740,12 @@ Casper.prototype.fill = function fill(selector, vals, submit) { | ... | @@ -740,6 +740,12 @@ Casper.prototype.fill = function fill(selector, vals, submit) { |
740 | var method = (form.getAttribute('method') || "GET").toUpperCase(); | 740 | var method = (form.getAttribute('method') || "GET").toUpperCase(); |
741 | var action = form.getAttribute('action') || "unknown"; | 741 | var action = form.getAttribute('action') || "unknown"; |
742 | __utils__.log('submitting form to ' + action + ', HTTP ' + method, 'info'); | 742 | __utils__.log('submitting form to ' + action + ', HTTP ' + method, 'info'); |
743 | var event = document.createEvent('Event'); | ||
744 | event.initEvent('submit', true, true); | ||
745 | if (!form.dispatchEvent(event)) { | ||
746 | __utils__.log('unable to submit form', 'warning'); | ||
747 | return; | ||
748 | } | ||
743 | if (typeof form.submit === "function") { | 749 | if (typeof form.submit === "function") { |
744 | form.submit(); | 750 | form.submit(); |
745 | } else { | 751 | } else { | ... | ... |
-
Please register or sign in to post a comment