This commit is contained in:
Josh at WLTechBlog 2025-08-19 09:55:09 -05:00
parent a69560849c
commit af2a0584de
1 changed files with 4 additions and 5 deletions

View File

@ -1975,16 +1975,15 @@ func (d *Daemon) selectElement(tabID, selector, value string, selectionTimeout,
changeScript := fmt.Sprintf("document.querySelector(\"%s\").dispatchEvent(new Event(\"change\", { bubbles: true }))", selector) changeScript := fmt.Sprintf("document.querySelector(\"%s\").dispatchEvent(new Event(\"change\", { bubbles: true }))", selector)
page.Eval(changeScript) page.Eval(changeScript)
// Verify the selection worked by checking the actual element value // Verify the selection worked by checking the element's value property directly
verifyScript := fmt.Sprintf("document.querySelector(\"%s\").value", selector) currentValue, err := element.Property("value")
result, err := page.Eval(verifyScript)
if err != nil { if err != nil {
return fmt.Errorf("failed to verify selection: %w", err) return fmt.Errorf("failed to verify selection: %w", err)
} }
// Check if the selection actually worked // Check if the selection actually worked
if result.Value.Nil() || result.Value.String() != value { if currentValue.Str() != value {
return fmt.Errorf("failed to select option '%s' in element", value) return fmt.Errorf("failed to select option '%s' in element (current value: %s)", value, currentValue.Str())
} }
} }