This commit is contained in:
Josh at WLTechBlog 2025-08-19 06:35:17 -05:00
parent bfbda8e6a3
commit 63068cd79e
1 changed files with 5 additions and 4 deletions

View File

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