Skip to content

Commit 2a9b68c

Browse files
committed
try-login: use requestSubmit for form submissions
`form.submit()` performs a low-level form submission that bypasses HTML validation, submit events, and submitter handling. `requestSubmit()` triggers the full browser submission flow, matching the behavior of a real user clicking the submit button, including form validation. https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/requestSubmit
1 parent eb25858 commit 2a9b68c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

brozzler/js-templates/try-login.js.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var __brzl_tryLogin = function() {
4242
console.log('submitting username=' + usernameField.value
4343
+ ' password=*** to detected login form');
4444
try {
45-
form.submit();
45+
form.requestSubmit();
4646
} catch (e) {
4747
// "If a form control (such as a submit button) has a name or
4848
// id of 'submit' it will mask the form's submit method." -MDN

tests/test_brozzling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def on_response(msg):
297297
login_url = "http://localhost:%s/login-action" % httpd.server_port
298298
# When username and password are defined and initial page has login form,
299299
# detect login form, submit login, and then return to the initial page.
300-
username = "user1"
300+
username = "user1@example.com" # input type="email"
301301
password = "pass1"
302302
with brozzler.Browser(chrome_exe=chrome_exe) as browser:
303303
browser.browse_page(

0 commit comments

Comments
 (0)