MCPcopy Create free account
hub / github.com/InverseUI/InverseUI-Recorder / handleChange

Method handleChange

modules/action/events/input.js:104–189  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

102 }
103
104 async handleChange(event) {
105 // Check recording state first
106 const recResponse = await this.sendMessageAsync({ message: "recState" });
107
108 if (!recResponse || !recResponse.recState) {
109 return;
110 }
111
112 const target = event.target;
113 const xpaths = this.getXpaths(target);
114
115 let changeData = {
116 message: "onChange",
117 xPath: xpaths,
118 content: target.value,
119 locator: getPlaywrightSelector(target)
120 };
121
122 if (target.type === 'checkbox' || target.type === 'radio') {
123 changeData.checked = target.checked;
124 changeData.value = target.value;
125 } else if (target.tagName === 'SELECT') {
126 // Capture comprehensive dropdown information (Layer 1: Native)
127 const selectedOptions = Array.from(target.selectedOptions).map(opt => ({
128 value: opt.value,
129 text: opt.text,
130 index: opt.index
131 }));
132
133 // Capture ALL available options
134 const allOptions = Array.from(target.options).map(opt => ({
135 value: opt.value,
136 text: opt.text,
137 index: opt.index,
138 selected: opt.selected,
139 disabled: opt.disabled
140 }));
141
142 changeData.dropdown = {
143 kind: 'native',
144 label: getLabelForElement(target),
145 selectedValue: target.value,
146 selectedText: target.selectedOptions[0]?.text || '',
147 selectedIndex: target.selectedIndex,
148 allOptions: allOptions,
149 isMultiple: target.multiple,
150 detectionConfidence: 1.0
151 };
152
153 // Keep backward compatibility
154 changeData.selectedOptions = selectedOptions;
155 } else if (target.type === 'file') {
156 changeData.files = Array.from(target.files || []).map(file => ({
157 name: file.name,
158 size: file.size,
159 type: file.type
160 }));
161 // Use real filename instead of browser's fakepath

Callers

nothing calls this directly

Calls 4

sendMessageAsyncMethod · 0.95
getPlaywrightSelectorFunction · 0.90
getLabelForElementFunction · 0.90
generateForElementMethod · 0.80

Tested by

no test coverage detected