Laravel Dusk: 元素在 (x, y) 点不可点击。其他元素将收到点击
Laravel Dusk: Element is not clickable at point (x, y). Other Element would receive the click
我正在尝试用 laravel Dusk
勾选复选框,其中包含其他可点击的链接,例如 Terms of Service
和 Privacy Policy
当我尝试在测试中选中此复选框时,出现以下错误
Element is not clickable at point (466, 438). Other element would receive the click: <label class="mt-checkbox mt-checkbox-outline">...</label>
这就是我想要做的
public function testRegister()
{
$template = factory(User::class)->make();
$this->browse(function (Browser $browser) use ($template) {
$browser
->visit(new Register)
->type('name', $template->name->full)
->type('phone', $template->phone)
->type('email', strtoupper($template->email))
->type('password', 'dummy-pass')
->check('agree')
->press('Create Account')
->assertRouteIs('dashboard')
->assertAuthenticated();
});
$this->assertDatabaseHas('users', [
'email' => $template->email,
]);
}
我尝试使用
最大化和滚动浏览器
$browser->maximize();
$browser->driver->executeScript('window.scrollTo(0, 400);');
除了使用 check
方法外,我还尝试将 click
方法与按钮选择器一起使用,例如
$browser->click('input#button-selector');
我找不到解决此问题的方法。有什么办法可以解决这个问题吗?我错过了什么吗?
我通过使用 outer label
选择器而不是复选框名称修复了它。例如,对于我的问题,这就是我对测试用例所做的。
public function testRegister()
{
$template = factory(User::class)->make();
$this->browse(function (Browser $browser) use ($template) {
$browser
->visit(new Register)
->type('name', $template->name->full)
->type('phone', $template->phone)
->type('email', strtoupper($template->email))
->type('password', 'dummy-pass')
->check('@agree')
->press('Create Account')
->assertRouteIs('dashboard')
->assertAuthenticated();
});
$this->assertDatabaseHas('users', [
'email' => $template->email,
]);
}
并且在我的 Register
页面中,我在 elements
方法中注册了 agree
选择器,如下所示
public function elements()
{
return [
'@agree' => 'label.mt-checkbox',
];
}
它确实通过使用复选框的外部标签选择器解决了我的问题。我希望这对以后的人有所帮助。
在我的情况下,它不起作用,因为我有两个具有相同元素的模态windows。
我正在尝试用 laravel Dusk
勾选复选框,其中包含其他可点击的链接,例如 Terms of Service
和 Privacy Policy
当我尝试在测试中选中此复选框时,出现以下错误
Element is not clickable at point (466, 438). Other element would receive the click: <label class="mt-checkbox mt-checkbox-outline">...</label>
这就是我想要做的
public function testRegister()
{
$template = factory(User::class)->make();
$this->browse(function (Browser $browser) use ($template) {
$browser
->visit(new Register)
->type('name', $template->name->full)
->type('phone', $template->phone)
->type('email', strtoupper($template->email))
->type('password', 'dummy-pass')
->check('agree')
->press('Create Account')
->assertRouteIs('dashboard')
->assertAuthenticated();
});
$this->assertDatabaseHas('users', [
'email' => $template->email,
]);
}
我尝试使用
最大化和滚动浏览器$browser->maximize();
$browser->driver->executeScript('window.scrollTo(0, 400);');
除了使用 check
方法外,我还尝试将 click
方法与按钮选择器一起使用,例如
$browser->click('input#button-selector');
我找不到解决此问题的方法。有什么办法可以解决这个问题吗?我错过了什么吗?
我通过使用 outer label
选择器而不是复选框名称修复了它。例如,对于我的问题,这就是我对测试用例所做的。
public function testRegister()
{
$template = factory(User::class)->make();
$this->browse(function (Browser $browser) use ($template) {
$browser
->visit(new Register)
->type('name', $template->name->full)
->type('phone', $template->phone)
->type('email', strtoupper($template->email))
->type('password', 'dummy-pass')
->check('@agree')
->press('Create Account')
->assertRouteIs('dashboard')
->assertAuthenticated();
});
$this->assertDatabaseHas('users', [
'email' => $template->email,
]);
}
并且在我的 Register
页面中,我在 elements
方法中注册了 agree
选择器,如下所示
public function elements()
{
return [
'@agree' => 'label.mt-checkbox',
];
}
它确实通过使用复选框的外部标签选择器解决了我的问题。我希望这对以后的人有所帮助。
在我的情况下,它不起作用,因为我有两个具有相同元素的模态windows。