0

Is there a best-practice for accessing cells programmatically via selectors?

I am trying to allow an e2e test easy access to the grid.

Lee Goddard
  • 10,680
  • 4
  • 46
  • 63

1 Answers1

1

How are you rendering your Grid? Are you using react-test-renderer or direct DOM injection using something like ReactTestUtils.renderIntoDocument() or ReactDOM.render()? If the latter 2, what I have done in my tests is add a custom CSS class in each cell rendered with a pattern like this:

  public static createCustomCellClass(rowIndex: number, columnIndex: number): string
  {
    return `pos-${rowIndex}-${columnIndex}`;
  }

Then, if I want to get access the DOM element for a cell I can use a selector like "div.pos-12-13" to get the cell at rowIndex 12 and columnIndex 13. That has worked well for me. What I found is that because all cells are just s that are absolutely positioned, it is not straightforward to get at a specific cell.

Pete Moss
  • 83
  • 7