laravel - 在 Laravel Dusk 中使用键盘
问题描述
Laravel 版本:
- “laravel/框架”:“^6.2”
- “laravel/黄昏”:“^5.9”
关于在 Laravel Dusk 中使用键盘的文档显示了以下语法:
$browser->keys('selector', ['{shift}', 'taylor'], 'otwell');
// or
$browser->keys('.app', ['{command}', 'j']);
在我的代码中,我有:
public function test_project_can_be_created()
{
$this->browse(function (Browser $browser) {
$browser
->loginAs($this->user)
->visit('/')
->click('a[href="'.route('projects.index').'"]')
->click('a[href="'.route('projects.create').'"]')
->keys('#app', ['{enter}']) // this is line 106
->type('project[name]', $this->faker->word)
->click('@submit');
}); // this is line 109
}
我想要实现的只是在浏览器中按“ENTER”键。然而...
当我运行时,php artisan dusk
我收到以下错误:
There was 1 error:
1) Tests\Browser\ProjectsTest::test_project_can_be_created
ErrorException: Array to string conversion
/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebElement.php:333 // https://github.com/php-webdriver/php-webdriver/blob/master/lib/Remote/RemoteWebElement.php#L333
/vendor/laravel/dusk/src/Concerns/InteractsWithElements.php:107 // https://github.com/laravel/dusk/blob/5.0/src/Concerns/InteractsWithElements.php#L107
/tests/Browser/ProjectsTest.php:106
/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:68
/tests/Browser/ProjectsTest.php:109
我错过了什么吗?我使用了错误的语法吗?
解决方案
推荐阅读
- postgresql - 在防火墙后面的 Windows 机器上手动安装 ora2pg [DBD::Oracle] 不能直接访问互联网
- kotlin - Room Database:如何嵌入具有 ArrayList 字段的对象模型?
- visual-c++ - 在实现 operator* 和 operator-> 运算符时出现错误。有人可以帮我解决什么问题吗?
- vb.net - 如何从上到下查找最低填充数组[最低填充] [尽可能均匀分布]
- r - 网络抓取 ESPN 的 NBA 数据时,有没有办法修复 HTTP 错误 403?
- android - ComposableLambda 如何在后台工作?
- asp.net - 现在学习 .NET Core 3.0 有意义吗?
- templates - 带有组名的Ansible目标模板?
- python - 使用 pyTelegramBotAPI,如何顺利编辑消息和内联标记?
- xcode - Xcode 注释键绑定与我的设置不同