MCPcopy
hub / github.com/ChromeDevTools/chrome-devtools-mcp / selectNativeSelectOption

Function selectNativeSelectOption

src/tools/input.ts:46–87  ·  view source on GitHub ↗
(handle: ElementHandle<Element>)

Source from the content-addressed store, hash-verified

44}
45
46async function selectNativeSelectOption(handle: ElementHandle<Element>) {
47 const selectHandle = await handle.evaluateHandle(node => {
48 if (!(node instanceof HTMLOptionElement)) {
49 return null;
50 }
51
52 const select = node.closest('select');
53 if (!select || select.multiple || select.disabled || node.disabled) {
54 return null;
55 }
56
57 const parentElement = node.parentElement;
58 if (
59 parentElement instanceof HTMLOptGroupElement &&
60 parentElement.disabled
61 ) {
62 return null;
63 }
64
65 return select;
66 });
67 try {
68 const select = selectHandle.asElement() as ElementHandle<Element> | null;
69 if (!select) {
70 return false;
71 }
72
73 const valueHandle = await handle.getProperty('value');
74 try {
75 const value = await valueHandle.jsonValue();
76 if (typeof value !== 'string') {
77 return false;
78 }
79 await select.asLocator().fill(value);
80 } finally {
81 void valueHandle.dispose();
82 }
83 return true;
84 } finally {
85 void selectHandle.dispose();
86 }
87}
88
89export const click = definePageTool({
90 name: 'click',

Callers 1

input.tsFile · 0.85

Calls 1

disposeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…