page_expectCount
Verify that the count of elements matching a selector exactly equals the expected number. Supports index-based selection and returns pass/fail result.
Instructions
一次性断言匹配选择器的元素数量是否「精确等于」expected(基于 page.$$,不是 >=)。支持 selector[index=N],此时命中该索引计 1、越界计 0。不抛错——结果在返回的 {pass,expected,actual,snapshot:{selector,index}} 的 pass 里,失败看 actual。⚠️ page.$$ 默认不穿透自定义组件(是否穿透取决于组件 styleIsolation/addGlobalClass,可用 page_getElements 看实际命中数判断),组件内部的元素不计入,会偏少。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expected | No | ||
| selector | Yes | ||
| connection | No | 可选连接覆盖(不传则用默认会话)。可用字段:mode(launch|connect)、cliPath、projectPath、wsEndpoint、timeout、port(【自动化端口】→ cli auto --auto-port,默认 9420;不是 IDE HTTP 服务端口,别把 IDE 服务端口传进来)、account、ticket、trustProject、args、cwd、autoClose、autoLaunch、launchTimeout、connectTimeout。 |