I am trying to get a rectangle's background color. I tried to find a way but i couldnt. Isnt there a method makes all this easy? Any help would be appriciated
Asked
Active
Viewed 377 times
2 Answers
1
Try this way
List<Node> chieldNode = new ArrayList<>();
chieldNode = ParentNode.getChildren();
if (chieldNode.size() != 0) {
for (Node node : chieldNode) {
if (node instanceof Rectangle ) {
Paint color = ((Rectangle ) node).getFill();
}
}
}

Keyur Bhanderi
- 1,524
- 1
- 11
- 17
-
But how can you reach to rectangle which is defined in applicaton's class not in test's class. – May 29 '17 at 11:31
-
1Replace parentNode to your application root node,here rectangle is a child node of parent node – Keyur Bhanderi May 29 '17 at 11:53
0
This worked for me
Rectangle rectangle = lookup("#rectangleId").queryAll().iterator().next();
Paint color = rect.getFill();
assertThat(color,is(color2));