나는 세 가지 유형의 사용자가있는 사이트에 대한 로그인 페이지가 있습니다. 사용자가 자신의 유형을 클릭하면 사용자가 클릭하는 유형에 따라 un/pw 필드가 나타납니다. 그러나 페이지 소스에는 세 가지 양식이 모두 있지만 두 가지 유형이 선택되어 있으므로 숨겨집니다. 나는에서 각 사용자 유형 로깅 테스트하는 behat 테스트를 작성하기 위해 노력하고있어 내 behat 테스트는 다음과 같습니다. 제가 페이지 소스를 볼 때가장 좋은 방법은 필드 테스트 및 필드가 동일한 이름을 때 작성 필드
@javascript @core
Feature: Secure Login
As a User
I expect to be asked for my credentials
So that I can use the system securely
Background:
Given I am logged out
Scenario: Failed User1 Login
When I go to user1 interface
When I submit incorrect user1 credentials
Then I should stay logged out
And I should see "The username or password entered does not match our records."
Scenario: Successful User1 Login
When I go to user1 interface
When I submit correct user1 credentials
Then I should be logged in to user1 interface
Scenario: Failed User2 Login
When I go to user2 interface
When I submit incorrect user2 credentials
Then I should stay logged out
And I should see "The username or password entered does not match our records."
Scenario: Successful User2 Login
When I go to user2 interface
When I submit correct user2 credentials
Then I should be logged in to user2 interface
, 여기에 내가 양식에 대한보고 내용은 다음과 같습니다
내 featurecontext 파일에서<form id='user1' name='user1' method="post" role="form">
<input type="hidden" name="subsystem" value="user1"/>
<label for="un1" class="label">Username</label>
<div id="un_inst1"class="label_instruction"></div>
<input autocapitalize="off" id="un1" autocorrect="off" type="text" name="username" value="" style="margin-bottom: 10px" aria-describedby="un_inst1">
<label for="pw1" class="label">Password</label>
<div id="pw_inst1"class="label_instruction"></div>
<input type="password" id="pw1" name="password" style="margin-bottom: 10px;" aria-describedby="pw_inst1">
<div class="login_buttons">
<input type="submit" value="Go" class="btn_go input-submit">
<input type="reset" class="btn_reset input-reset" value="Reset">
<br/>
</div>
</form>
<form id='user2' name='user2' method="post" role="form">
<input type="hidden" name="subsystem" value="resident"/>
<div class="usr-login label">Resident Login</div>
<label for="un2" class="label">Username</label>
<div id="un_inst2"class="label_instruction"></div>
<input autocapitalize="off" autocorrect="off" type="text" id="un2" name="username" value="" style="margin-bottom: 10px" aria-describedby="un_inst2">
<label for="pw2" class="label">Password</label>
<div id="pw_inst2"class="label_instruction"></div>
<input type="password" id="pw2" name="password" style="margin-bottom: 10px;" aria-describedby="pw_inst2">
<div class="login_buttons">
<input type="submit" value="Go" class="btn_go input-submit">
<input type="reset" class="btn_reset input-reset" value="Reset">
<br/>
</div>
</form>
, 나는 이러한 기능을 가지고 :
은 $ 인터페이스는 사용자 1 또는 사용자 2입니다public function iSubmitIncorrectCredentials($interface)
{
$button ='Go';
return $this->login("tester" . time(), "bar", $button);
}
private function login($username, $password, $btn)
{
$this->fillField('username', $username);
$this->fillField('password', $password);
$this->pressButton($btn);
}
.
{"errorMessage":"Element is not currently interactable and may not be manipulated","request":{"headers":{"Accept":"application/json;charset=UTF-8","Content-Length":"36","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:8643"},"httpVersion":"1.1","method":"POST","post":"{\"value\":[\"tester1479232631\\ue004\"]}","url":"/value","urlParsed":{"anchor":"","query":"","file":"value","directory":"/","path":"/value","relative":"/value","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/value","queryKey":{},"chunks":["value"]},"urlOriginal":"/session/ea0f7000-ab5c-11e6-acb9-5946ec8fdb06/element/:wdc:1479232631203/value"}} (WebDriver\Exception\InvalidElementState)
내가 무슨 일이 일어나고 생각하는 fillField()가 이름을 찾기 위해 노력하고 있다는 것입니다 : 제가하는 데 문제는 내가 사용자 2 시험에 도착하면 사용자 1 패스에 대한 테스트,하지만 난이 오류가 있다는 것입니다 필드가 있지만 두 가지가 있습니다. user1의 경우 테스트가 작동하지만 user2의 경우 오류가 발생합니다. un/pw 필드의 이름을 변경하는 것 외에도이를 처리하는 방법에 대한 조언이 필요합니다. 감사합니다.
내 답변이 도움이되기를 바랍니다. 문제가있는 경우 알려 주시고 내일 구체적인 코드를 추가하겠습니다. – lauda