Laravel dusk 在文本区域内看不到文本
Laravel dusk don't see text inside textarea
我想测试一下,如果我在 textarea 中键入一个词,那么我应该在 textarea 中看到该词。
/** @test */
public function type_a_word_should_see_a_word()
{
$this->browse(function (Browser $browser) {
$browser->visit('/test')
->keys('textarea', 'hello')
->with('textarea', function ($textarea) {
$textarea->assertSee('hello');
});
});
}
断言失败,“在元素 [body textarea] 中没有看到预期的文本 [hello]。
无法断言 false 是 true。"
但是我可以从屏幕截图中看到"hello"这个词,我的代码有什么问题吗?
使用 ->assertValue($textarea,'hello')
而不是 ->assertSee()
我认为代码应该是这样的:
public function type_a_word_should_see_a_word()
{
$this->browse(function (Browser $browser) {
$browser->visit('/test')
->keys('textarea', 'hello')
->assertValue('textarea','hello')
});
}
我想测试一下,如果我在 textarea 中键入一个词,那么我应该在 textarea 中看到该词。
/** @test */
public function type_a_word_should_see_a_word()
{
$this->browse(function (Browser $browser) {
$browser->visit('/test')
->keys('textarea', 'hello')
->with('textarea', function ($textarea) {
$textarea->assertSee('hello');
});
});
}
断言失败,“在元素 [body textarea] 中没有看到预期的文本 [hello]。 无法断言 false 是 true。"
但是我可以从屏幕截图中看到"hello"这个词,我的代码有什么问题吗?
使用 ->assertValue($textarea,'hello')
而不是 ->assertSee()
我认为代码应该是这样的:
public function type_a_word_should_see_a_word()
{
$this->browse(function (Browser $browser) {
$browser->visit('/test')
->keys('textarea', 'hello')
->assertValue('textarea','hello')
});
}