Laravel Dusk 无法断言看到屏幕截图中可见的文本(使用 whenAvailable 作为模态)

标签 laravel laravel-dusk browser-testing

我写了一个 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.

截图:

enter image description here

我做错了什么?

最佳答案

我有一个解决方法。我添加了 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/

相关文章:

php - 如何在php中使用数据库中的数据设置“阅读更多”按钮

php - 在 laravel API 中使用 session

php - 如何使用 Laravel Dusk 测试身份验证?

php - 如何使用 Laravel 5.5 禁用 Chrome 的 Dusk headless 模式?

php - Laravel 黄昏 : unknown error: call function result missing 'value'

testing - 驱动多个相互交互的浏览器

javascript - Python:实际上可以在 splitter 中访问文件上传吗?

laravel - 代客 (Laravel) : DNS address can not be found

unit-testing - 如何在本地或 Jenkins 上*自动化*基于浏览器的单元测试

php - Composer 安装要求