我正在尝试为学习目的进行简单的验收测试。这是一个简单的身份验证场景:用户输入/admin
,如果没有登录,他会被重定向/login
到填写表格。
当我运行测试时,我收到此错误:
1) Couldn't login with a password protected area in LoginCest.loginUserWithProperCredentials
Guy couldn't fill field "username","rafael": Field matching id|name|label|value or css or xpath selector does not exist
Scenario Steps:
5. I fill field "username","rafael" <==== RED
4. I see current url equals "/login"
3. I am on page "/admin"
2. So that I Perform administrative tasks
1. As a Site Owner
现在这是我的观点:
//create.blade.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
</head>
<body>
<h1>Login</h1>
{{ Form::open() }}
<div>
{{ Form::Label('username', 'Username') }}
{{ Form::Text('username', '') }}
</div>
<div>
{{ Form::label('password', 'Password') }}
{{ Form::password('password', '') }}
</div>
<div>
{{ Form::submit('Login') }}
</div>
{{ Form::close() }}
</body>
</html>
这是测试:
class LoginCest
{
public function loginUserWithProperCredentials(WebGuy $I){
$I->am("Site Owner");
$I->wantTo("Login with a password protected area");
$I->lookForwardTo("Perform administrative tasks");
$I->amOnPage('/admin');
$I->seeCurrentUrlEquals('/login');
$I->fillField('username', 'rafael');
$I->fillField("password", "123456");
$I->click("Login");
$I->seeCurrentUrlEquals("/admin");
$I->see("Admin area", "h1");
}
}
任何帮助,将不胜感激。