I am working on simple java standalone application with GUI created with JavaFX 8.
I wrote some tests of GUI with TestFX framework (version 3.1.0). On my local machine tests works fine, but they are failed on Travis CI environment. Please take a look, some fragments of code:
import static org.assertj.core.api.Assertions.assertThat;
import static org.loadui.testfx.GuiTest.find;
public class JavafxApplicationIT {
private static GuiTest controller;
@BeforeClass
public static void setAfter() throws Exception {
FXTestUtils.launchApp(JavafxApplication.class);
Thread.sleep(5000);
controller = new GuiTest() {
@Override
protected Parent getRootNode() {
return JavafxApplication.getScene().getRoot();
}
};
}
@AfterClass
public static void shutdownAll() throws InterruptedException {
Platform.runLater(() -> JavafxApplication.getStage().close());
}
@Test
public void shouldFillForm_saveLicence_thenOpen_andVerifySignature() throws Throwable {
controller.click("#newLicenceButton");
((TextField) find("#licenceUidField")).setText(licenceUID);
((TextField) find("#customerIdField")).setText(customerId);
....
controller.click("#mainActionButton");
Thread.sleep(3000);
((TextField) find("#licFileField")).setText(licenceFile.getPath()); // <--- FAILED
}
}
I've got No nodes matched '#licFileField'
error. I notice that in every failing cases problem with matching is always after opening some new window in application.
In above case, clicking on mainActionButton
invokes new window, and licFileField
is a name of element from new (active) window.
Maybe it is connected with configuration of xvfb on Travis CI machine? In .travis.yml
I've got:
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"