feat: add support for select, textarea, and file upload in web forms
Extend form handling to support: - <select> dropdowns: detect options, select by visible text or value - <textarea> fields: fill with text content - <input type="file">: upload files by absolute path - All element types are also discovered inside shadow DOM Changes: - find_inputs.js: discover <select> (with options) and <textarea> - browser.py: import Select, handle new element types in get_form_inputs() and fill_form_inputs()
This commit is contained in:
@@ -11,6 +11,37 @@ function findInputs(element, result = []) {
|
||||
displayed: isElementDisplayed(input)
|
||||
});
|
||||
});
|
||||
// Find all <select> elements (dropdowns / multi-choice)
|
||||
const selects = element.querySelectorAll('select');
|
||||
selects.forEach(select => {
|
||||
const options = Array.from(select.options).map(opt => ({
|
||||
value: opt.value,
|
||||
text: opt.textContent.trim(),
|
||||
selected: opt.selected
|
||||
}));
|
||||
result.push({
|
||||
tagName: select.tagName,
|
||||
text: select.name || '',
|
||||
type: 'select',
|
||||
class: select.className || '',
|
||||
xpath: getXPath(select),
|
||||
displayed: isElementDisplayed(select),
|
||||
multiple: select.multiple,
|
||||
options: options
|
||||
});
|
||||
});
|
||||
// Find all <textarea> elements
|
||||
const textareas = element.querySelectorAll('textarea');
|
||||
textareas.forEach(textarea => {
|
||||
result.push({
|
||||
tagName: textarea.tagName,
|
||||
text: textarea.name || '',
|
||||
type: 'textarea',
|
||||
class: textarea.className || '',
|
||||
xpath: getXPath(textarea),
|
||||
displayed: isElementDisplayed(textarea)
|
||||
});
|
||||
});
|
||||
const allElements = element.querySelectorAll('*');
|
||||
allElements.forEach(el => {
|
||||
if (el.shadowRoot) {
|
||||
|
||||
Reference in New Issue
Block a user