2.0.1 • Published 2 years ago
@dlenroc/roku-dom v2.0.1
@dlenroc/roku-dom · 
DOM-like representation of the app-ui
Installation
npm install @dlenroc/roku-domUsage
⚠️
render()must be called for synchronizing DOM with application state
import { Document } from '@dlenroc/roku-dom';
import { ECPExecutor } from '@dlenroc/roku-ecp';
import { ODCExecutor } from '@dlenroc/roku-odc';
const document = new Document({
  ecp: new ECPExecutor({ address: 'http://<ip>:8060' }),
  odc: new ODCExecutor({ address: 'http://<ip>:8061' }),
});
// Sync DOM
await document.render();
const element = document.cssSelect('[text="Play"]');
console.log(element?.isFocused);Document
Everything from Element ➕
get context(): 'ECP' | 'ODC'set context(context: 'ECP' | 'ODC')get fields(): Record<string, string[]>set fields(fields: Record<string, string[]>)get focusedElement(): Elementget isKeyboardShown(): booleanrender(): Promise<void>Element
get sdk(): SDKget document(): Documentget parent(): Element | nullget parents(): Element[]get siblings(): Element[]get prev(): Element | nullget next(): Element | nullget children(): Element[]get tag(): stringget path(): stringget index(): numberget attributes(): Record<string, string>get text(): stringget bounds(): Rect | nullget isConnected(): booleanget isFocused(): booleanget isInFocusChain(): booleanget isDisplayed(): booleanisSameNode(element: Element): booleanclear(): Promise<void>type(text: string): Promise<void>append(text: string): Promise<void>select(): Promise<void>focus(): Promise<void>cssSelect(css: string): Element | nullcssSelect(css: string, timeoutInSeconds: number): Promise<Element | null>cssSelectAll(css: string): Element[]cssSelectAll(css: string, timeoutInSeconds: number): Promise<Element[]>xpathSelect(xpath: string): Element | nullxpathSelect(xpath: string, timeoutInSeconds: number): Promise<Element | null>xpathSelectAll(xpath: string): Element[]xpathSelectAll(xpath: string, timeoutInSeconds: number): Promise<Element[]>toString(): string