vaadin / testbench

Vaadin TestBench is a tool for automated user interface testing of Vaadin applications.
https://vaadin.com/testbench
Other
20 stars 22 forks source link

TabElement.getText() is empty when running tests on Firefox #1714

Open mlindfors opened 9 months ago

mlindfors commented 9 months ago

Problem

Currently TabElement.getText(), and consequently anything relying on the return value of that method, is broken when running tests using the latest Firefox. Instead of returning the tab title, the value is just empty.

Apparently this problem isn't limited to just the TabElement, it might just be that pretty much anything using getText() is not working correctly.

Steps to reproduce

To reproduce, get a Vaadin 23 skeleton starter project from start.vaadin.com, and add the following to the MainView class:

        Tabs tabs = new Tabs();
        tabs.add(new Tab("About"));
        tabs.add(new Tab("Info"));
        add(tabs);

Change the WebDriver in use from ChromeDriver to FirefoxDriver in AbstractTestView, run the application, and add the following test to the MainViewIT class and run it:

    @Test
    public void testTabs() {
        TabsElement tabs = $(TabsElement.class).waitForFirst();
        String title = tabs.getSelectedTabElement().getText();
        int index = tabs.getTab("About");
        System.out.println("About tab's index is " + index);
        System.out.println("Selected tab's title text is " + title);
    }

You will end up with return values of "-1" and "". If you use tabs.getSelectedTabElement().getWrappedElement().getDomProperty("innerHTML"); you will get the Tab title, but of course the tabs.getTab("About"); will return -1 no matter what.

Expected result

The tab text and the tab index are returned properly. This happens when testing with Chrome or Safari.

Versions

macOS Sonoma 14.2 Verified with Vaadin 23.3.29, I would expect this to be similarly broken with Vaadin 24. Firefox 120.0.1

mshabarov commented 9 months ago

Related issue https://github.com/vaadin/flow-components/issues/5646.

Waits until Firefox 122 release, see https://github.com/vaadin/flow-components/issues/5646#issuecomment-1822804146.