Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes are invisible in headless tests for Ludo #72

Open
LeStegii opened this issue Mar 24, 2024 · 2 comments
Open

Nodes are invisible in headless tests for Ludo #72

LeStegii opened this issue Mar 24, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed low-priority

Comments

@LeStegii
Copy link
Collaborator

Describe the bug
When testing the Ludo game in headless mode, the tests fail because the bot cannot click on nodes (not visible).

To Reproduce
Steps to reproduce the behavior:

  1. Run the tests in headless

Expected behavior
The tests shouldn't fail becaues the nodes are visible.

Desktop (please complete the following information):

  • OS: Windows

Additional context
The nodes exist and can be used (e.g. using tabs and enter), but they cannot be found when clicked as they are apparently not visible on screen (see #67)

@LeStegii LeStegii added the bug Something isn't working label Mar 24, 2024
@LeStegii LeStegii changed the title Nodes are invisible in headless tests Nodes are invisible in headless tests for Ludo Mar 24, 2024
@LeStegii
Copy link
Collaborator Author

LeStegii commented May 6, 2024

When using a real headless enviroment everything seems to work fine.
On Windows the node cannot be found and an error is thrown.
On MAC, it doesn't throw an error but the node isn't clicked.

@LeStegii LeStegii added low-priority help wanted Extra attention is needed labels May 6, 2024
@Clashsoft
Copy link
Member

Please use this code for testing:

public class BadControllerTest extends ControllerTest {
    @Test
    void bad() {

        try {
            FxAssert.verifyThat("some button that does not exist", Node::isVisible, collectInfos());
        } catch (Exception ex) {
            printInfos();
        }
    }

    public void printInfos() {
        System.err.println(collectInfos().apply(new StringBuilder()));
    }

    public Function<StringBuilder, StringBuilder> collectInfos() {
        final Path dir = Paths.get("build", "failed-test-screenshots");
        try {
            Files.createDirectories(dir);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return DebugUtils.compose(
            DebugUtils.insertHeader("Context:"),
            DebugUtils.showKeysPressedAtTestFailure(this),
            DebugUtils.showMouseButtonsPressedAtTestFailure(this),
            DebugUtils.showFiredEvents(),
            DebugUtils.saveWindow(
                stage,
                () -> dir.resolve(getClass().getSimpleName() + " " + LocalTime.now() + ".png"),
                null));
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed low-priority
Projects
None yet
Development

No branches or pull requests

2 participants