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":
|
case "select":
|
||||||
// For select elements, use JavaScript to set the value
|
// For select elements, set the value using JavaScript
|
||||||
script := fmt.Sprintf(`
|
script := fmt.Sprintf("this.value = '%s'; this.dispatchEvent(new Event('change', { bubbles: true })); true", interaction.Value)
|
||||||
(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)
|
|
||||||
|
|
||||||
result, err := element.Eval(script)
|
result, err := element.Eval(script)
|
||||||
if err != nil {
|
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() {
|
} else if result.Value.Bool() {
|
||||||
interactionResult.Success = true
|
interactionResult.Success = true
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue