From 439ae4b5f79abf422054e417d1fc97a9f854a93e Mon Sep 17 00:00:00 2001 From: Josh at WLTechBlog Date: Mon, 18 Aug 2025 15:10:59 -0500 Subject: [PATCH] multiple --- daemon/daemon.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 5d1f0f9..198c96c 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -3497,13 +3497,16 @@ 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 JavaScript - script := fmt.Sprintf("this.value = '%s'", interaction.Value) - _, jsErr := element.Eval(script) + // Try to find and select by matching option value using page.Eval to avoid element.Eval issues + script := fmt.Sprintf(` + const element = document.querySelector("%s"); + if (element) { + element.value = "%s"; + element.dispatchEvent(new Event('change', { bubbles: true })); + } + `, interaction.Selector, interaction.Value) + _, jsErr := page.Eval(script) if jsErr == nil { - // Trigger change event - _, _ = element.Eval("this.dispatchEvent(new Event('change', { bubbles: true }))") - // Verify the JavaScript selection worked by checking the element's value currentValue, err := element.Property("value") if err != nil { @@ -3514,7 +3517,7 @@ func (d *Daemon) interactMultiple(tabID, interactionsJSON string, timeout int) ( interactionResult.Error = fmt.Sprintf("failed to select option: %s (current value: %s)", interaction.Value, currentValue.Str()) } } else { - interactionResult.Error = fmt.Sprintf("failed to select option: %v", err) + interactionResult.Error = fmt.Sprintf("failed to select option: %v", jsErr) } } else { interactionResult.Success = true