0

I'm trying to write some TestFX code that will loop through a TableView component and check the background colour for each row is set correctly.

What I can't work out is how to actually construct the loop to go through the TableRows as opposed to the actual data. I've tried using sourceTable.getItems() but that just gives me access to the object containing the data. But I need to go lower down than that and actually examine the background-colour of the CSS tag.

I know that a TableRow has a getStyle function, which will return the data I'm looking for, but I'm at a loss at how to construct the appropriate iteration that will go through each individual row.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • Welcome to Stack Overflow! Other users marked your question for low quality and need for improvement. I re-worded/formatted your input to make it easier to read/understand. Please review my changes to ensure they reflect your intentions. Feel free to drop me a comment in case you have further questions or feedback for me. – GhostCat Oct 04 '18 at 06:24

1 Answers1

-1

My first thought is to use queryAccessibleAttribute() method.. but unfortunately it is not working working as expected. May be someone can correct me.

for (int i=0;i<tableView.getItems().size();i++){
    TableRow row = (TableRow) tableView.queryAccessibleAttribute(AccessibleAttribute.ROW_AT_INDEX,i);
}

So as of now use lookup() for the rendered tablerows.

Set<Node> tableRows = tableView.lookupAll("TableRow");
Sai Dandem
  • 8,229
  • 11
  • 26
  • no, that's useless because they are not even available for all items in the table but only for the currently visible items – kleopatra Oct 04 '18 at 09:43