Questions tagged [testfx]

Simple and clean testing for JavaFX.

Simple and clean testing for JavaFX.

Features:

  • A fluent and clean API.
  • Flexible setup and cleanup of JavaFX test fixtures.
  • Simple robots to simulate user interactions.
  • Rich collection of matchers to verify expected states.

Support for:

  • Java 8 features and JavaFX 8 controls.
  • JUnit testing framework and Hamcrest matchers.
  • Precise screenshots of failed tests.
  • Headless testing using Monocle.

Sample:

 public class DesktopPaneTest extends ApplicationTest {
    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new DesktopPane(), 800, 600);
        stage.setScene(scene);
        stage.show();
    }

    @Test
    public void should_drag_file_into_trashcan() {
        // given:
        rightClickOn("#desktop").moveTo("New").clickOn("Text Document");
        write("myTextfile.txt").push(ENTER);

        // when:
        drag(".file").dropTo("#trash-can");

        // then:
        verifyThat("#desktop", hasChildren(0, ".file"));
    }
 }

As you can see above, TestFX is emulating GUI action with simple methods like drag(String) or write(String). You are able to call the JavaFX-Components directly via the CSS-ID or CSS-Class string. To call the id you have to add a # before the id, to reach the class you need a . before the classname.

Links:

108 questions
0
votes
1 answer

ScenicView 8.7.0 does not load the opened JAVA FX application in it to inspect the elements

I have ScenicView 8.7.0 installed with JDK 8. I need to inspect the JAVA FX application which is running on Ubuntu 16.04(Hope Linux version is not the concern). ScenicView does find the opened JAVA FX application as per the following logs, but in UI…
Pravin W
  • 31
  • 9
0
votes
1 answer

TestFX clickOn method is not recognized

I built a simple calculator with JavaFX, now I want to test it and it is proving to be quite a challenge. I found out about a library called TestFX which seems to be perfect for testing my calculator. After adding the following…
Alexandre Krabbe
  • 727
  • 1
  • 13
  • 33
0
votes
0 answers

Latest version of testfx supported in java 7

The closest I can find for this is this stackoverflow question, but that seems to say the 4.0.0-alpha has issues since it was compiled against java 8. Currently, we're using 3.1.2, but this is definitely missing some functionality. Does anyone have…
Zyxer22
  • 152
  • 8
0
votes
1 answer

UnsatisfiedLinkError:Native Library jdk1.8.0_121\jre\bin\glass.dll already loaded in another classloader

I have a project I use maven and intellij. I write my test function using TestFX, Mocito and PowerMock but when I run test one by one all tests are passed. But when I start to run all test it gives this exception. I searched and I add…
0
votes
2 answers

Implementing TestFX in the Eclipse

I would like to write tests to my project in JavaFX and I've read that I have to use TestFX, so I want to implement the library to my eclipse. But I still can't resolve my problem (look at picture). I was looking for a solution but it was…
XtrEmE
  • 13
  • 6
0
votes
2 answers

TestFX How to understand the color of an item?

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
user4887078
0
votes
2 answers

NoClassDefFoundError, FxRobotException, FatalBeanException and ExecutionException while running gradle test

I am trying to run TestFX tests with gradle on offline machine. With command like gradle -Dtest.single=ViewsTest test On one machine it runs well, but on another machine it fails with NoClassDefFoundError: org.testfx.api.FxRobotException This…
Dims
  • 47,675
  • 117
  • 331
  • 600
0
votes
1 answer

How to do it in TestFX 4?

I have a question about testFx 4. There is a GUI object, where I want to set text into TextField ("#searchField"). It's works in TestFx 3 as follows: //Load FXML @Override protected Parent getRootNode() { Parent parent = null; try { FXMLLoader…
Ruslan Gabbazov
  • 732
  • 7
  • 21
0
votes
1 answer

Is TestFX compatible with Java 7?

Running the following snippet (with JDK 7 set in Eclipse): import javafx.scene.Scene; import javafx.stage.Stage; import org.junit.Test; import org.testfx.framework.junit.ApplicationTest; public class BasicTestFxTest extends ApplicationTest { …
mre
  • 43,520
  • 33
  • 120
  • 170
0
votes
1 answer

TestFX and Gradle - NoNodeFoundException

testFx already works in Eclipse and the GUI tests run successfully. But it does not work with gradle. It gives me the NoNodeFoundException on a button. If I get rid of that line of code that it shows me the very same exception for the next line…
Quatsch
  • 361
  • 1
  • 8
  • 29
0
votes
1 answer

EclEmma "Coverage As" Eclipse JUnit Thread Death

I have the below JUnit4 test written using TestFX to test the GUI (JavaFX) of a particular product (a to-do list), along with two necessary classes. The first class is the main class which manages the whole GUI, while the second is the class for the…
Aaa
  • 134
  • 1
  • 8
0
votes
1 answer

TestFX 4: Can't use simply verifyThat(), have to use the whole import name

I suspect there is something weird going on in my project setup. When I try to just use the method verifyThat() the compiler can't find it and I get an error in my program, but when I write out the whole thing,…
TAsk
  • 153
  • 2
  • 11
0
votes
2 answers

@Test Annotiation not working with TestFX

I'm trying to implement TextFX in my project to do some UI testing. However it seems I can't get it to work properly. I've downloaded the jars from http://search.maven.org/#search%7Cga%7C1%7Ctestfx to a folder named 'TestFX-3.1.2' on my…
Perneel
  • 3,317
  • 7
  • 45
  • 66
0
votes
1 answer

How to write a string in textfield which contains underscore in it using TestFX?

I am writing a simple login form in JavaFX for which I am writing a test program in TestFX. My TestFX script automatically types the credentials in the textfields and clicks the login button and it works fine further. But when I want the script to…
Kuldeep Verma
  • 104
  • 1
  • 12
-1
votes
1 answer

TestFx retrieve elements content of HTML in WebView

I am writing tests in my JavaFX application using TestFx. It is going good till i access FXML elements but i am wonder how to access WebView HTML content. WebView is a major part of my application so i have to add tests for that. Below is my HTML…
Sumeet Vishwas
  • 585
  • 1
  • 6
  • 18