How do I wait for a component in TestBench

For example I have code such that:


which then fires off a thread and the view is updated through

currentUI.access(() → textfield.setValue(something));

This could take a few seconds so right now I’m trying polling (Thread.sleep() and so on) but it seems to cause the unit testing thread to sleep. I’ve even tried a callback method but that gives a locking error.

In essence I’m trying to do something like:


I’ve gone through the documentation and although it seems to allude that this is possible I can’t find anything: I even tried awaitility but it had the same issue as Thread.sleep().

Any suggestions would be greatly appreciated.

Just to add I did see a waitUntil in the Vaadin 14 documentation at: but I can’t seem to call this code nor do I see any mention in the latest documentation. So I’m wondering if it’s available…

And my test is running from UIUnitTest rather than end to end testing

I don’t think that you can test asynchronous code on the unit test

Ah. That’s too bad. So I have to use end to end testing then only. If I may suggest it would be a good thing to add in the future.

Also just an FYI the documentation on has sample code that extends BrowserTestBase but it’s not referred to anything. In fact you would probably want to extend TestBenchTestCase. I suspect BrowserTestBase is from some other sample code that is not in the sample code…

I’m not a Vaadin employee.

Ah. My bad. Sorry about that.

Thank you answering my question.

You should check the issues and open a new one if none exists Issues · vaadin/testbench · GitHub

Good idea.

Thank you