gpt4 book ai didi

php - Laravel Dusk NoSuchElementException/无法定位元素

转载 作者:可可西里 更新时间:2023-11-01 12:58:24 27 4
gpt4 key购买 nike

我正在尝试运行一些基本的 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)

我的注册测试:

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');
});
}

我的注册页面:

 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>

最佳答案

对于那些仍然有问题的人:检查 Laravel 的 .env 文件中的 APP_URL 变量。应用程序运行的 URL 必须与 APP_URL 参数匹配

关于php - Laravel Dusk NoSuchElementException/无法定位元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48567518/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com