Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Arekan127's avatar

Get translated text in waitForText(), Dusk, dusk, dusk....

Hi, I will be very grateful if community will help solve my problem with testing. I have multilingual app(11 languages) And I want to see text on page depending on language what I'm testing. I tried $browser->waitForText(trans('proof-of-use.title')); And I get back fail Facebook\WebDriver\Exception\TimeOutException: Waited 5 seconds for text [proof-of-use.title]. Hope someone can explain why that happend and how to fix it

0 likes
2 replies
bobbybouwmann's avatar
Level 88

The BrowserTest class is extending the PhpUnit test class by default. Therefore you can't access Laravel specific functions when running these tests. You can only use the browser tests functions!

I would also recommend you to leave these translation out of your tests like you do now. Instead write a test where you say switch language to some language and assert some translations using static text. This way you have full control over the tests ;)

1 like
Arekan127's avatar

Thank you for answer. You are right, this will be the best option

Please or to participate in this conversation.