import type { JSHandle } from 'puppeteer-core'; import type PageOptions from '../types/PageOptions'; import getPage from './getPage'; /** * Get the `textContent` property of a DOM element. * @param {string} selector The selector to use. * @param {PageOptions} options * @returns {Promise} The `textContent` value. */ export default function getTextContent(selector: string, options?: PageOptions) { const page = getPage(options); return page .waitForSelector(selector) .then((element) => element!.getProperty('textContent')) .then((property: JSHandle) => property.jsonValue()); }