MCPcopy
hub / github.com/ZToolsCenter/ZTools / check

Method check

resources/zbrowser/client.js:600–613  ·  view source on GitHub ↗

* 设置复选框状态 * * @param {string} selector - CSS 选择器 * @param {boolean} checked - 是否选中(默认 true) * @returns {ZBrowserClient} this

(selector, checked)

Source from the content-addressed store, hash-verified

598 * @returns {ZBrowserClient} this
599 */
600 check(selector, checked) {
601 return this.evaluate(
602 (selector, checked) => {
603 const el = document.querySelector(selector)
604 if (!el) {
605 throw new Error('check: unable to find element by selector "' + selector + '"')
606 }
607 el.checked = checked === undefined ? true : checked === true
608 el.dispatchEvent(new window.Event('change', { bubbles: true, cancelable: true }))
609 },
610 selector,
611 checked
612 )
613 }
614
615 /**
616 * 聚焦元素

Callers

nothing calls this directly

Calls 1

evaluateMethod · 0.95

Tested by

no test coverage detected