This commit is contained in:
Josh at WLTechBlog 2025-08-18 13:43:05 -05:00
parent dda9dbe915
commit 3364ce6a0a
1 changed files with 19 additions and 17 deletions

View File

@ -3494,27 +3494,29 @@ func (d *Daemon) interactMultiple(tabID, interactionsJSON string, timeout int) (
case "select": case "select":
// For select elements, use JavaScript to set the value // For select elements, use JavaScript to set the value
script := fmt.Sprintf(` script := fmt.Sprintf(`
const element = arguments[0]; (function() {
if (element.tagName.toLowerCase() === 'select') { const element = arguments[0];
// Try to select by value first if (element.tagName.toLowerCase() === 'select') {
for (let option of element.options) { // Try to select by value first
if (option.value === '%s') { for (let option of element.options) {
element.value = '%s'; if (option.value === '%s') {
element.dispatchEvent(new Event('change', { bubbles: true })); element.value = '%s';
return true; element.dispatchEvent(new Event('change', { bubbles: true }));
return true;
}
} }
} // Try to select by text if value didn't work
// Try to select by text if value didn't work for (let option of element.options) {
for (let option of element.options) { if (option.text === '%s') {
if (option.text === '%s') { element.value = option.value;
element.value = option.value; element.dispatchEvent(new Event('change', { bubbles: true }));
element.dispatchEvent(new Event('change', { bubbles: true })); return true;
return true; }
} }
return false;
} }
return false; return false;
} })()
return false;
`, interaction.Value, interaction.Value, interaction.Value) `, interaction.Value, interaction.Value, interaction.Value)
result, err := element.Eval(script) result, err := element.Eval(script)