This commit is contained in:
Josh at WLTechBlog 2025-08-19 06:36:47 -05:00
parent 63068cd79e
commit a6489cd5d0
1 changed files with 1 additions and 10 deletions

View File

@ -1966,16 +1966,7 @@ func (d *Daemon) selectElement(tabID, selector, value string, selectionTimeout,
if err != nil { if err != nil {
// If text selection failed, use JavaScript as fallback // If text selection failed, use JavaScript as fallback
// This handles both option value and option text selection // This handles both option value and option text selection
script := fmt.Sprintf(` script := fmt.Sprintf(`document.querySelector("%s").value = "%s"; document.querySelector("%s").dispatchEvent(new Event('change', { bubbles: true })); document.querySelector("%s").value`, selector, value, selector, selector)
var el = document.querySelector("%s");
if(el) {
el.value = "%s";
el.dispatchEvent(new Event('change', { bubbles: true }));
el.value;
} else {
null;
}
`, selector, value)
// Execute JavaScript and get the result // Execute JavaScript and get the result
result, err := page.Eval(script) result, err := page.Eval(script)