e2ed
Version:
E2E testing framework over Playwright
22 lines (21 loc) • 898 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContentFromRenderedElement = void 0;
const asserts_1 = require("../asserts");
/**
* Get element content (innerHTML) from rendered element.
* @internal
*/
const getContentFromRenderedElement = (renderedElement) => {
const contentWithTags = String(renderedElement).trim();
(0, asserts_1.assertValueIsTrue)(contentWithTags.startsWith('<'), 'contentWithTags starts with tag', {
contentWithTags,
});
(0, asserts_1.assertValueIsTrue)(contentWithTags.endsWith('>'), 'contentWithTags ends with tag', {
contentWithTags,
});
const openTagIndex = contentWithTags.indexOf('>');
const closeTagIndex = contentWithTags.lastIndexOf('<');
return contentWithTags.slice(openTagIndex + 1, closeTagIndex);
};
exports.getContentFromRenderedElement = getContentFromRenderedElement;