import * as playwright from "playwright" ; import { RethrownError } from "../utils/RethrownError" ; import { EnsureXrmGetter } from "./Global" ; import { XrmUiTest } from "./XrmUITest" ; import { D365Selectors } from "../domain/D365Selectors" ; /**
 * Module for interacting with D365 Grids / Entity Lists
 */ export class Grid { private _page : playwright . Page ; constructor ( private xrmUiTest ) { this . _page = xrmUiTest . page ; this . xrmUiTest = xrmUiTest ; } param { Number } recordNumber returns { Promise < void > } openNthRecord = async ( recordNumber ) => { const rowToClick = await this . _page . $ ( D365Selectors . Grid . DataRowWithIndexCheckBox . replace ( "{0}" , `${ recordNumber + 2 }` ) ) ; if ( rowToClick ) { await rowToClick . dblclick ( ) ; await this . xrmUiTest . waitForIdleness ( ) ; } else { throw new Error ( `Failed to find grid row ${ recordNumber }` ) ; } } ; param { Number } recordNumber returns { Promise < void > } selectNthRecord = async ( recordNumber ) => { const rowToClick = await this . _page . $ ( D365Selectors . Grid . DataRowWithIndexCheckBox . replace ( "{0}" , `${ recordNumber + 2 }` ) ) ; if ( rowToClick ) { await rowToClick . click ( ) ; await this . xrmUiTest . waitForIdleness ( ) ; } else { throw new Error ( `Failed to find grid row ${ recordNumber }` ) ; } } ; }