我正在尝试运行一些基本的Laravel Dusk测试,但总是遇到Facebook WebDriver的问题:
我已将chrome更新为最新版本,并使用Hombrew手动更新了Chrome WebDriver:
有什么建议吗?
干杯,斯坦
错误:
Tests\Browser\Tests\Auth\SignUpTest::a_user_can_sign_up
Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body textarea[name='input[name="name"]']"}
(Session info: headless chrome=64.0.3282.119)
(Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.12.6 x86_64)
MySignUpTest:
public function a_user_can_sign_up()
{
$this->browse(function (Browser $browser) {
$browser->visit(new SignUpPage)
->signUp('Erika Musterfrau', 'erika.musterfrau@socialite.ch', 'password', 'password')
->assertPathIs('/dashboard')
->assertSeeIn('.navbar', 'Erika Musterfrau');
});
}
MySignUpPage:
public function assert(Browser $browser)
{
$browser->assertPathIs('/register');
}
public function signUp(Browser $browser, $name = null, $email = null, $password = null, $passwordConfirmation = null)
{
$browser->type('@name', $name)
->type('@email', $email)
->type('@password', $password)
->type('@password_confirmation', $passwordConfirmation)
->press('Register');
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@name' => 'input[name="name"]',
'@email' => 'input[name="email"]',
'@password' => 'input[name="password"]',
'@password_confirmation' => 'input[name="password_confirmation"]',
];
}
OneOfMyRegisterInputViews:
<div class="form-group row">
<div class="col-lg-8 offset-2">
<input placeholder="name"
type="text"
class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}"
name="name"
value="{{ old('name') }}"
required
>
@if ($errors->has('name'))
<div class="invalid-feedback">
<strong>{{ $errors->first('name') }}</strong>
</div>
@endif
</div>
</div>
答案 0 :(得分:0)
对于仍然有问题的用户:检查Laravel .env文件中的APP_URL变量。运行应用程序的URL必须与APP_URL参数匹配