I am unable to capture the sorter from the grid element in order to test via UI that the sorting works on version: com.vaadin:vaadin-testbench-core:6.2.1
As pointed by another user, GridElement::getHeaderCell returns the th in Grid’s shadow DOM, but in order to trigger sort or query the direction attribute one needs to retrieve the vaadin-grid-sorter element that is inside of the slotted cell:
The sorter returns as null and any other direct interactions on the element do not result in any interaction with the element.
th.click(), th,contextClick().
Might have found a solution after 2 days of trying. Yuriy’s suggestion also put me on the right track.
This snippet does the job to click on the header and sort the column.
Difference is getting the wrapped element as a generic Webelement instead of GridTHTDElement. Casting the element as GridTHTDElement will throw an exception when trying to use getHeaderCellContent().