菜单
文档breadcrumb arrow Grafana k6breadcrumb arrow JavaScript APIbreadcrumb arrow k6/browserbreadcrumb arrow Framebreadcrumb arrow innerText(selector[, options])
开源

innerText(selector[, options])

警告

请改用基于 locator 的 locator.innerText([options])

返回 element.innerText 的值。

参数类型默认值描述
selector字符串''用于搜索元素的 selector。如果多个元素满足该 selector,将使用第一个。
options对象null
options.strict布尔值false当为 true 时,要求 selector 解析为单个元素。如果给定的 selector 解析为多个元素,调用将抛出异常。
options.timeout数字30000最大超时时间(毫秒)。传入 0 表示禁用超时。默认值会被 BrowserContextPage 上的 setDefaultTimeout 选项覆盖。

返回值

类型描述
Promise<string>一个 Promise,当成功时将返回元素的内部文本(表示元素句柄及其后代的渲染文本内容)。