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

textContent(selector[, options])

警告

请改用基于定位器的 locator.textContent([options])

返回元素的 element.textContent

参数类型默认值描述
selectorstring''用于查找元素的选取器。如果存在多个满足条件的元素,将使用第一个。
optionsobjectnull
options.strictbooleanfalse当为 true 时,调用要求选取器解析为单个元素。如果给定的选取器解析为多个元素,调用将抛出异常。
options.timeoutnumber30000最大时间,单位为毫秒。传递 0 以禁用超时。默认值会被 BrowserContextPage 上的 setDefaultTimeout 选项覆盖。

返回值

类型描述
Promise<string | null>一个 Promise,它会使用选取器的文本内容或 null 来 fulfilled。