multiple
This commit is contained in:
parent
dd55c67ad4
commit
439ae4b5f7
|
@ -3497,13 +3497,16 @@ func (d *Daemon) interactMultiple(tabID, interactionsJSON string, timeout int) (
|
||||||
err = element.Select([]string{interaction.Value}, true, rod.SelectorTypeText)
|
err = element.Select([]string{interaction.Value}, true, rod.SelectorTypeText)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If text selection failed, the value might be the actual option value
|
// If text selection failed, the value might be the actual option value
|
||||||
// Try to find and select by matching option value using JavaScript
|
// Try to find and select by matching option value using page.Eval to avoid element.Eval issues
|
||||||
script := fmt.Sprintf("this.value = '%s'", interaction.Value)
|
script := fmt.Sprintf(`
|
||||||
_, jsErr := element.Eval(script)
|
const element = document.querySelector("%s");
|
||||||
|
if (element) {
|
||||||
|
element.value = "%s";
|
||||||
|
element.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
|
}
|
||||||
|
`, interaction.Selector, interaction.Value)
|
||||||
|
_, jsErr := page.Eval(script)
|
||||||
if jsErr == nil {
|
if jsErr == nil {
|
||||||
// Trigger change event
|
|
||||||
_, _ = element.Eval("this.dispatchEvent(new Event('change', { bubbles: true }))")
|
|
||||||
|
|
||||||
// Verify the JavaScript selection worked by checking the element's value
|
// Verify the JavaScript selection worked by checking the element's value
|
||||||
currentValue, err := element.Property("value")
|
currentValue, err := element.Property("value")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3514,7 +3517,7 @@ func (d *Daemon) interactMultiple(tabID, interactionsJSON string, timeout int) (
|
||||||
interactionResult.Error = fmt.Sprintf("failed to select option: %s (current value: %s)", interaction.Value, currentValue.Str())
|
interactionResult.Error = fmt.Sprintf("failed to select option: %s (current value: %s)", interaction.Value, currentValue.Str())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
interactionResult.Error = fmt.Sprintf("failed to select option: %v", err)
|
interactionResult.Error = fmt.Sprintf("failed to select option: %v", jsErr)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
interactionResult.Success = true
|
interactionResult.Success = true
|
||||||
|
|
Loading…
Reference in New Issue