I am using https://github.com/TestFX/TestFX for gui tests of a javafx client. With a testfx query I get the comboBox but I cannot get its text for verification. The comboBox displays enum values whose text is resolved by a converter and a given resource bundle. The scene graph for the comboBox looks like that:
javafx.scene.control.ComboBox
javafx.scene.layout.StackPane:arrow-button
javafx.scene.layout.Region:arrow
com.sun.javafx.scene.control.skin.ComboBoxListViewSkin$4$1:null
com.sun.javafx.scene.control.skin.LabeledText:null
comboBox.getValue()
gives me only the enum value but not the text (I could verify the enum value but since it is a gui test the displayed text should be verified). By trying out I found out that comboBox.getChildrenUnmodifiable().toString()
prints
[StackPane[id=arrow-button, styleClass=arrow-button], ComboBoxListViewSkin$5[id=list-view, styleClass=list-view], ComboBoxListViewSkin$4$1@4f65f1d7[styleClass=cell indexed-cell list-cell]'StringOfInterest']
The string 'StringOfInterest' at the end is exactly what I need but it is unclear where it comes from. By looking into the source code of javafx it seems that Node#toString is being used. However, it is unclear where the last part ('StringOfInterest') comes from. I tried to get the text of all children of the ComboBox but the string in question is not part of it.
How can I extract the string?