Matching nodes were found, but none of them were visible.

699 views
Skip to first unread message

ry...@jaeb.ca

unread,
Sep 12, 2014, 7:39:01 PM9/12/14
to testfx-...@googlegroups.com
Hi,

I'm trying out TestFX and I'm having trouble getting a simple test working.  I have a very simple pane with two list views; one on the left, one on the right.  I'm trying to use the following test (I intentionally removed everything except the part that I'm having trouble with):


However, I get an exception when I run it:

org.loadui.testfx.exceptions.NoNodesVisibleException: Matching nodes were found, but none of them were visible. Screenshot saved as C:\Projects\fx-testing\screenshot1410564516973.png.
at org.loadui.testfx.GuiTest.getVisibleNodes(GuiTest.java:238)
at org.loadui.testfx.GuiTest.find(GuiTest.java:466)

The screenshot saved by TestFX looks like this:


...but what I actually see on the screen is this:


Any idea what I'm doing wrong?

Benjamin Gudehus

unread,
Sep 12, 2014, 7:44:23 PM9/12/14
to ry...@jaeb.ca, testfx-...@googlegroups.com
Hi Ryan!

I expect the error here:

~~~java
controller.getLeftListView().getItems().add("test item");
click("test item");
~~~

Seems that click() does not search for the ListItem with the label "test item".

I'll try to reproduce this error with a simple ListView.

Regards
Benjamin



--
You received this message because you are subscribed to the Google Groups "TestFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testfx-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benjamin Gudehus

unread,
Sep 12, 2014, 7:45:51 PM9/12/14
to ry...@jaeb.ca, testfx-...@googlegroups.com
Also: Could you try to add Thread.sleep(2000) before click()?

ry...@jaeb.ca

unread,
Sep 12, 2014, 8:08:58 PM9/12/14
to testfx-...@googlegroups.com, ry...@jaeb.ca
Thanks for the fast reply.  Adding Thread.sleep(2000) makes it work.  Also, I use a presentation model design and noticed I get a different error when I access the list via the model:

 org.loadui.testfx.exceptions.NoNodesFoundException: No nodes matched 'Node should have label "test item"'. Screenshot saved as C:\Projects\fx-testing\screenshot1410566515369.png.
at org.loadui.testfx.GuiTest.assertNodesFound(GuiTest.java:244)
at org.loadui.testfx.GuiTest.find(GuiTest.java:465)

My model has:

private ListProperty<String> leftList = new SimpleListProperty<>(FXCollections.observableArrayList());
public ListProperty<String> leftListProperty() {return leftList;}

... which is bound in the controller:

model.leftListProperty().bindBidirectional(leftListView.itemsProperty());

I'm confused as to why accessing the list via the model makes any difference:

controller.getModel().getLeftList().add("test item");

Ryan

tbeernot

unread,
Sep 12, 2014, 9:58:23 PM9/12/14
to testfx-...@googlegroups.com
The sleep is probably not the best solution, it is most likely indicative of a synchronisation problem; you need to wait for the skin to catch up with the data that is in the controller. Maybe you should try adding a "waitForPaintPulse" or something similar. Look at what I did in JFXtras:
https://github.com/JFXtras/jfxtras/blob/8.0/jfxtras-controls/src/test/java/jfxtras/scene/control/test/ListSpinnerArrowTest.java
https://github.com/JFXtras/jfxtras/blob/8.0/jfxtras-test-support/src/main/java/jfxtras/test/TestUtil.java

ry...@jaeb.ca

unread,
Sep 13, 2014, 1:27:33 AM9/13/14
to testfx-...@googlegroups.com
Tom, that sounds right to me and your 'waitForPaintPulse' solution works.  I didn't mean to imply I was going to use Thread.sleep as a solution, just that it was enough of a delay to let things sync up properly.

I don't quite understand how TestFX works when it comes to threading.  Are there multiple threads working that I need to be concerned about?  My (unresearched) assumption was that everything I did would run on a single thread and that I wouldn't have to think about synchronization issues.

Thanks again for the help guys,
Ryan
Reply all
Reply to author
Forward
0 new messages