Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:DevExpress Testcafe NodeSnapshot TypeDefs

From Leeroopedia
Knowledge Sources
Domains Type_Definitions, Testing, DOM_Querying
Last Updated 2026-02-12 12:00 GMT

Overview

Concrete TypeScript type declarations for the NodeSnapshot interface representing a serialized snapshot of a DOM element's state captured from the browser.

Description

NodeSnapshot contains comprehensive element information: node properties (nodeType, textContent, childNodeCount), element properties (tagName, id, className, attributes, visible), geometry (clientWidth/Height, offsetWidth/Height, scrollWidth/Height, boundingClientRect), styling (style, focused, value, checked, selected), and navigation (hasChildElements, hasChildNodes). This is what await Selector(...) resolves to.

Usage

Use NodeSnapshot types when working with awaited selector results in TypeScript to access element properties with full type safety.

Code Reference

Source Location

Signature

interface NodeSnapshot {
    // Node properties
    nodeType: number;
    textContent: string;
    childNodeCount: number;
    hasChildNodes: boolean;
    childElementCount: number;
    hasChildElements: boolean;

    // Element properties
    tagName: string;
    id: string;
    attributes: { [name: string]: string };
    visible: boolean;
    focused: boolean;
    value: string;
    checked: boolean;
    selected: boolean;
    selectedIndex: number;
    classNames: string[];
    className: string;
    namespaceURI: string;
    innerHTML: string;
    innerText: string;

    // Geometry
    clientWidth: number;
    clientHeight: number;
    clientTop: number;
    clientLeft: number;
    offsetWidth: number;
    offsetHeight: number;
    offsetTop: number;
    offsetLeft: number;
    scrollWidth: number;
    scrollHeight: number;
    scrollTop: number;
    scrollLeft: number;
    boundingClientRect: { left: number; right: number; top: number; bottom: number; width: number; height: number; };

    // Style
    style: { [prop: string]: string };

    // Child access
    getStyleProperty(propertyName: string): string;
    getAttribute(attributeName: string): string;
    getBoundingClientRectProperty(propertyName: string): number;
    hasClass(className: string): boolean;
    getChildElement(idx: number): NodeSnapshot;
    getChildNode(idx: number): NodeSnapshot;
    hasAttribute(attrName: string): boolean;
}

Import

// Available as global type in TestCafe test files
import { Selector } from 'testcafe';
// const snapshot: NodeSnapshot = await Selector('#el');

I/O Contract

Inputs

Name Type Required Description
(resolved from Selector) SelectorPromise Yes Awaiting a Selector produces a NodeSnapshot

Outputs

Name Type Description
NodeSnapshot object All DOM element properties at the time of capture

Usage Examples

import { Selector } from 'testcafe';

fixture('NodeSnapshot').page('https://example.com');

test('Access element snapshot', async (t: TestController) => {
    const el = await Selector('#main-heading');

    // Access snapshot properties
    console.log(el.tagName);          // 'h1'
    console.log(el.textContent);       // 'Welcome'
    console.log(el.visible);           // true
    console.log(el.boundingClientRect.width); // 800

    // Check attributes
    const hasId = el.hasAttribute('id');
    const dataValue = el.getAttribute('data-testid');

    // Check classes
    const isActive = el.hasClass('active');

    // Child access
    const firstChild = el.getChildElement(0);
});

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment