GWT add ids to the datagrids as a whole, its headers and rows

39 views Asked by At

I'm struggling to give several ids to my data grids using gwt in order to ease the frontend testing using robotframework with selenium library.

How can I add an id to each header and row of the data grid or cell grid?

And to the whole datagrid?

Thanks in advance.

1

There are 1 answers

0
collder On

GWT has DebugInfo class which creates dbg attribute where you can add your custom information. So you can do like this for example:

String dataGridId = "custom id for element";
someWidget.setAttribute(DebugInfo.getDebugIdAttribute(), dataGridId));

And your selenium can find element:

webDriver.findElement(By.cssSelector("*[dbg='" + dataGridId + "']"))

This way will work for whole data grid. To search headers with selenium you can just compare text from header itself the same way

webDriver.findElement(By.anyMethod())).getText()

Actually you can .getText() from any WebElement