我写了一个 Laravel Dusk 测试。我试图断言在模式打开后是否可以看到某些文本。所以,我正在使用 whenAvailable
方法。但是当我可以在屏幕截图中看到文字时它失败了。
$browser->press('@finish-setup-button')
->whenAvailable('#modal-payment-info', function ($modal) use($paymentInfo) {
$modal->assertSee(html_entity_decode(__('account_setup.payment')))
->type('name', $paymentInfo->name)
->type('iban', $paymentInfo->iban)
->type('bic', $paymentInfo->bic)
->press('@subscribe-button');
});
我收到以下消息:
There was 1 failure:
1) Tests\Browser\RegistrationTest::testRegistration Did not see expected text [Payment] within element [body #modal-payment-info]. Failed asserting that false is true.
截图:
我做错了什么?
最佳答案
我有一个解决方法。我添加了 1 秒的暂停,效果很好。
$browser->press('@finish-setup-button')
->whenAvailable('#modal-payment-info', function ($modal) use($paymentInfo) {
$modal->pause(1000)
->assertSee(html_entity_decode(__('account_setup.payment')))
->type('name', $paymentInfo->name)
->type('iban', $paymentInfo->iban)
->type('bic', $paymentInfo->bic)
->press('@subscribe-button');
});
关于Laravel Dusk 无法断言看到屏幕截图中可见的文本(使用 whenAvailable 作为模态),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53059584/