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)
page.Eval(changeScript)
// Verify the selection worked by checking the actual element value
verifyScript := fmt.Sprintf("document.querySelector(\"%s\").value", selector)
result, err := page.Eval(verifyScript)
// Verify the selection worked by checking the element's value property directly
currentValue, err := element.Property("value")
if err != nil {
return fmt.Errorf("failed to verify selection: %w", err)
}
// Check if the selection actually worked
if result.Value.Nil() || result.Value.String() != value {
return fmt.Errorf("failed to select option '%s' in element", value)
if currentValue.Str() != value {
return fmt.Errorf("failed to select option '%s' in element (current value: %s)", value, currentValue.Str())
}
}