diff --git a/daemon/daemon.go b/daemon/daemon.go index bf0d2c1..a631311 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -3498,13 +3498,7 @@ func (d *Daemon) interactMultiple(tabID, interactionsJSON string, timeout int) ( if err != nil { // If text selection failed, the value might be the actual option value // Try to find and select by matching option value using page.Eval to avoid element.Eval issues - script := fmt.Sprintf(` - var element = document.querySelector("%s"); - if (element) { - element.value = "%s"; - element.dispatchEvent(new Event('change', { bubbles: true })); - } - `, interaction.Selector, interaction.Value) + script := fmt.Sprintf(`(function(){ var el = document.querySelector("%s"); if(el) { el.value = "%s"; el.dispatchEvent(new Event('change', { bubbles: true })); } })()`, interaction.Selector, interaction.Value) _, jsErr := page.Eval(script) if jsErr == nil { // Verify the JavaScript selection worked by checking the element's value