Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

test(webdriver): wait for form navigation with BiDi attached

ldm0fc2a45a9eb01
diff --git a/moli-protocol-server/src/protocol_server/tests/bidi/extracted/script_runtime.rs b/moli-protocol-server/src/protocol_server/tests/bidi/extracted/script_runtime.rs
index bd9e6fb2f..857f01dfa 100644
--- a/moli-protocol-server/src/protocol_server/tests/bidi/extracted/script_runtime.rs
+++ b/moli-protocol-server/src/protocol_server/tests/bidi/extracted/script_runtime.rs
@@ -108,7 +108,10 @@ async fn websocket_bidi_attached_classic_session_title_waits_for_script_triggere
"POST",
&format!("/session/{session_id}/execute/sync"),
json!({
- "script": "document.querySelector('form').submit(); return 'submitted';",
+ // Form submission plans a later DOM task. Wait for navigation to
+ // start so the title command tests an in-flight load while BiDi
+ // is attached, rather than racing the planned submission task.
+ "script": "return new Promise(resolve => { navigation.addEventListener('navigate', () => resolve('submitted'), { once: true }); document.querySelector('form').submit(); });",
"args": []
}),
)