Skip to content

Commit 3820ed5

Browse files
committed
try-login: trigger input events on form fields
Following up on 2a9b68c. Some pages have custom input validation that is triggered when input focus changes, this change triggers those events. Additionally, `try-login.js` could run before the page is ready, so a delay was added to ensure the page is ready before filling the form.
1 parent 2a9b68c commit 3820ed5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

brozzler/browser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,10 @@ def try_login(self, username, password, timeout=300):
948948
.render(username=username, password=password)
949949
)
950950

951+
self.logger.info("trying to login")
952+
time.sleep(1) # allow time for any scripts to run
953+
self._wait_for_idle(idle_time=2, timeout=4)
954+
951955
self.websock_thread.got_page_load_event = None
952956
self.send_to_chrome(
953957
method="Runtime.evaluate",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ var __brzl_tryLogin = function() {
3939
if (usernameField && passwordField) {
4040
usernameField.value = {{username|json}};
4141
passwordField.value = {{password|json}};
42+
// Trigger input and change events for username and password fields
43+
for (const field of [usernameField, passwordField]) {
44+
field.dispatchEvent(new Event("input", { bubbles: true }));
45+
field.dispatchEvent(new Event("change", { bubbles: true }));
46+
field.blur();
47+
}
4248
console.log('submitting username=' + usernameField.value
4349
+ ' password=*** to detected login form');
4450
try {

0 commit comments

Comments
 (0)