multiple
This commit is contained in:
parent
f96d344020
commit
0f3b287591
|
@ -3492,34 +3492,11 @@ func (d *Daemon) interactMultiple(tabID, interactionsJSON string, timeout int) (
|
|||
}
|
||||
|
||||
case "select":
|
||||
// For select elements, use JavaScript to set the value
|
||||
script := fmt.Sprintf(`
|
||||
(function() {
|
||||
if (this.tagName.toLowerCase() === 'select') {
|
||||
// Try to select by value first
|
||||
for (var i = 0; i < this.options.length; i++) {
|
||||
if (this.options[i].value === '%s') {
|
||||
this.value = '%s';
|
||||
this.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Try to select by text if value didn't work
|
||||
for (var i = 0; i < this.options.length; i++) {
|
||||
if (this.options[i].text === '%s') {
|
||||
this.value = this.options[i].value;
|
||||
this.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).call(this)
|
||||
`, interaction.Value, interaction.Value, interaction.Value)
|
||||
|
||||
// For select elements, set the value using JavaScript
|
||||
script := fmt.Sprintf("this.value = '%s'; this.dispatchEvent(new Event('change', { bubbles: true })); true", interaction.Value)
|
||||
result, err := element.Eval(script)
|
||||
if err != nil {
|
||||
interactionResult.Error = fmt.Sprintf("failed to execute select script: %v", err)
|
||||
interactionResult.Error = fmt.Sprintf("failed to select option: %v", err)
|
||||
} else if result.Value.Bool() {
|
||||
interactionResult.Success = true
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue