Skip to content

Commit ff7aebd

Browse files
aldro61claude
andcommitted
Fix chart tasks failing with findElementInShadowDOM not defined
When all init scripts are merged into a single string and registered via add_init_script, function declarations are not accessible from outside the init script context (e.g. via iframe.evaluate_handle). Explicitly assigning the function to window ensures it is globally accessible regardless of how the merged script is scoped. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent eeadb4e commit ff7aebd

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/browsergym/workarena/tasks/utils/js_utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function findElementInShadowDOM(selector, root = document) {
3434
// Return null if the element is not found in any shadow root
3535
return null;
3636
}
37+
// Explicitly expose on window so it is accessible via frame.evaluate_handle()
38+
// when all init scripts are merged into a single string (see base.py).
39+
window.findElementInShadowDOM = findElementInShadowDOM;
3740

3841

3942
/**

0 commit comments

Comments
 (0)