diff --git a/daemon/daemon.go b/daemon/daemon.go index a631311..107519a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -3497,21 +3497,19 @@ func (d *Daemon) interactMultiple(tabID, interactionsJSON string, timeout int) ( err = element.Select([]string{interaction.Value}, true, rod.SelectorTypeText) 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 + // Try to find and select by matching option value using page.Eval 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 - currentValue, err := element.Property("value") - if err != nil { - interactionResult.Error = fmt.Sprintf("failed to verify selection: %v", err) - } else if currentValue.Str() == interaction.Value { - interactionResult.Success = true - } else { - interactionResult.Error = fmt.Sprintf("failed to select option: %s (current value: %s)", interaction.Value, currentValue.Str()) - } + // Execute JavaScript and ignore any rod evaluation quirks + page.Eval(script) + + // Always verify success by checking the element's actual value + currentValue, err := element.Property("value") + if err != nil { + interactionResult.Error = fmt.Sprintf("failed to verify selection: %v", err) + } else if currentValue.Str() == interaction.Value { + interactionResult.Success = true } else { - interactionResult.Error = fmt.Sprintf("failed to select option: %v", jsErr) + interactionResult.Error = fmt.Sprintf("failed to select option: %s (current value: %s)", interaction.Value, currentValue.Str()) } } else { interactionResult.Success = true