MCPcopy
hub / github.com/Fosowl/agenticSeek / findInputs

Function findInputs

sources/web_scripts/find_inputs.js:1–52  ·  view source on GitHub ↗
(element, result = [])

Source from the content-addressed store, hash-verified

1function findInputs(element, result = []) {
2 // Find all <input> elements in the current DOM tree
3 const inputs = element.querySelectorAll('input');
4 inputs.forEach(input => {
5 result.push({
6 tagName: input.tagName,
7 text: input.name || '',
8 type: input.type || '',
9 class: input.className || '',
10 xpath: getXPath(input),
11 displayed: isElementDisplayed(input)
12 });
13 });
14 // Find all <select> elements (dropdowns / multi-choice)
15 const selects = element.querySelectorAll('select');
16 selects.forEach(select => {
17 const options = Array.from(select.options).map(opt => ({
18 value: opt.value,
19 text: opt.textContent.trim(),
20 selected: opt.selected
21 }));
22 result.push({
23 tagName: select.tagName,
24 text: select.name || '',
25 type: 'select',
26 class: select.className || '',
27 xpath: getXPath(select),
28 displayed: isElementDisplayed(select),
29 multiple: select.multiple,
30 options: options
31 });
32 });
33 // Find all <textarea> elements
34 const textareas = element.querySelectorAll('textarea');
35 textareas.forEach(textarea => {
36 result.push({
37 tagName: textarea.tagName,
38 text: textarea.name || '',
39 type: 'textarea',
40 class: textarea.className || '',
41 xpath: getXPath(textarea),
42 displayed: isElementDisplayed(textarea)
43 });
44 });
45 const allElements = element.querySelectorAll('*');
46 allElements.forEach(el => {
47 if (el.shadowRoot) {
48 findInputs(el.shadowRoot, result);
49 }
50 });
51 return result;
52}
53// function to get the XPath of an element
54function getXPath(element) {
55 if (!element) return '';

Callers 1

find_inputs.jsFile · 0.85

Calls 3

getXPathFunction · 0.85
isElementDisplayedFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected