This commit is contained in:
Josh at WLTechBlog 2025-08-18 13:50:04 -05:00
parent 60b717efbd
commit f888ab8026
1 changed files with 8 additions and 9 deletions

View File

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