bump
This commit is contained in:
parent
35a2ed62c7
commit
e2e44b40e2
|
@ -1965,31 +1965,8 @@ func (d *Daemon) selectElement(tabID, selector, value string, selectionTimeout,
|
||||||
err = element.Select([]string{value}, true, rod.SelectorTypeText)
|
err = element.Select([]string{value}, true, rod.SelectorTypeText)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If text selection failed, use JavaScript as fallback
|
// If text selection failed, use JavaScript as fallback
|
||||||
// This handles both option value and option text selection
|
// Use a single-line approach that works with rod's evaluation
|
||||||
script := fmt.Sprintf(`
|
script := fmt.Sprintf(`(() => { const select = document.querySelector("%s"); if (!select) return null; select.value = "%s"; if (select.value === "%s") { select.dispatchEvent(new Event('change', { bubbles: true })); return select.value; } for (let i = 0; i < select.options.length; i++) { if (select.options[i].text === "%s") { select.selectedIndex = i; select.dispatchEvent(new Event('change', { bubbles: true })); return select.value; } } return null; })()`, selector, value, value, value)
|
||||||
var select = document.querySelector("%s");
|
|
||||||
var result = null;
|
|
||||||
if (select) {
|
|
||||||
// First try to select by value
|
|
||||||
select.value = "%s";
|
|
||||||
if (select.value === "%s") {
|
|
||||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
result = select.value;
|
|
||||||
} else {
|
|
||||||
// If value selection failed, try to find by text content
|
|
||||||
var options = select.options;
|
|
||||||
for (var i = 0; i < options.length; i++) {
|
|
||||||
if (options[i].text === "%s") {
|
|
||||||
select.selectedIndex = i;
|
|
||||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
result = select.value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result;
|
|
||||||
`, selector, value, value, value)
|
|
||||||
|
|
||||||
// Execute JavaScript and get the result
|
// Execute JavaScript and get the result
|
||||||
result, err := page.Eval(script)
|
result, err := page.Eval(script)
|
||||||
|
@ -3599,31 +3576,8 @@ 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, use JavaScript as fallback
|
// If text selection failed, use JavaScript as fallback
|
||||||
// This handles both option value and option text selection
|
// Use a single-line approach that works with rod's evaluation
|
||||||
script := fmt.Sprintf(`
|
script := fmt.Sprintf(`(() => { const select = document.querySelector("%s"); if (!select) return null; select.value = "%s"; if (select.value === "%s") { select.dispatchEvent(new Event('change', { bubbles: true })); return select.value; } for (let i = 0; i < select.options.length; i++) { if (select.options[i].text === "%s") { select.selectedIndex = i; select.dispatchEvent(new Event('change', { bubbles: true })); return select.value; } } return null; })()`, interaction.Selector, interaction.Value, interaction.Value, interaction.Value)
|
||||||
var select = document.querySelector("%s");
|
|
||||||
var result = null;
|
|
||||||
if (select) {
|
|
||||||
// First try to select by value
|
|
||||||
select.value = "%s";
|
|
||||||
if (select.value === "%s") {
|
|
||||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
result = select.value;
|
|
||||||
} else {
|
|
||||||
// If value selection failed, try to find by text content
|
|
||||||
var options = select.options;
|
|
||||||
for (var i = 0; i < options.length; i++) {
|
|
||||||
if (options[i].text === "%s") {
|
|
||||||
select.selectedIndex = i;
|
|
||||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
result = select.value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result;
|
|
||||||
`, interaction.Selector, interaction.Value, interaction.Value, interaction.Value)
|
|
||||||
|
|
||||||
// Execute JavaScript and get the result
|
// Execute JavaScript and get the result
|
||||||
result, err := page.Eval(script)
|
result, err := page.Eval(script)
|
||||||
|
@ -3820,31 +3774,8 @@ func (d *Daemon) fillFormBulk(tabID, formSelector, fieldsJSON string, timeout in
|
||||||
err = element.Select([]string{fieldValue}, true, rod.SelectorTypeText)
|
err = element.Select([]string{fieldValue}, true, rod.SelectorTypeText)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If text selection failed, use JavaScript as fallback
|
// If text selection failed, use JavaScript as fallback
|
||||||
// This handles both option value and option text selection
|
// Use a single-line approach that works with rod's evaluation
|
||||||
script := fmt.Sprintf(`
|
script := fmt.Sprintf(`(() => { const select = document.querySelector("%s"); if (!select) return null; select.value = "%s"; if (select.value === "%s") { select.dispatchEvent(new Event('change', { bubbles: true })); return select.value; } for (let i = 0; i < select.options.length; i++) { if (select.options[i].text === "%s") { select.selectedIndex = i; select.dispatchEvent(new Event('change', { bubbles: true })); return select.value; } } return null; })()`, fieldResult.Selector, fieldValue, fieldValue, fieldValue)
|
||||||
var select = document.querySelector("%s");
|
|
||||||
var result = null;
|
|
||||||
if (select) {
|
|
||||||
// First try to select by value
|
|
||||||
select.value = "%s";
|
|
||||||
if (select.value === "%s") {
|
|
||||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
result = select.value;
|
|
||||||
} else {
|
|
||||||
// If value selection failed, try to find by text content
|
|
||||||
var options = select.options;
|
|
||||||
for (var i = 0; i < options.length; i++) {
|
|
||||||
if (options[i].text === "%s") {
|
|
||||||
select.selectedIndex = i;
|
|
||||||
select.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
result = select.value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result;
|
|
||||||
`, fieldResult.Selector, fieldValue, fieldValue, fieldValue)
|
|
||||||
|
|
||||||
// Execute JavaScript and get the result
|
// Execute JavaScript and get the result
|
||||||
jsResult, err := page.Eval(script)
|
jsResult, err := page.Eval(script)
|
||||||
|
|
Loading…
Reference in New Issue