0

웹 사이트에 대한 수락/기능 테스트를 작성 중입니다. 다음과 같은 문제가 있습니다.링크를 통해 에뮬레이션 할 수 없습니다. 허용되지 않는 오류 (# 405)

공통 모드에서
<ul class="b"> 
<li ng-repeat="item2 in item.items" class="ng-scope"> 
    <a href="/persons/personaccount/index" class="ng-binding">Account</a> 
</li><li ng-repeat="item2 in item.items" class="ng-scope"> 
    <a href="/persons/persontype/index" class="ng-binding">Person type</a> 
</li><li ng-repeat="item2 in item.items" class="ng-scope"> 
    <a href="/persons/person/index" class="ng-binding">Person</a> 
</li> 
</ul> 

, 내가 자유롭게 항목을 클릭 할 수 있습니다 웹 사이트에

는 메뉴가있다.

$I->click('//*[@class="b"]/li[last()]/a'); 

그럼 내가 필요로하는 페이지를로드 : 하나 개의 연속 Cept- 파일에서 나는 메서드를 호출 할 수 있습니다.

클래스와 비슷한 Cest 형식을 사용하면 문제가 발생합니다 (선호합니다). 승인을 통과하는 메소드에서이 호출을하면 다음과 같습니다.

public function tryToDoSomething(FunctionalTester $I) 
{ 
    $I->amOnPage('/site/login'); 

    $I->fillField('#loginform-username','admin'); 
    $I->fillField('#loginform-password','admin'); 

    $I->seeElement('button', ['name' => 'login-button']); 

    $I->click('#login-form button[type=submit]'); 

    $I->wait(5); 

    $I->cantSee('....', '.error-block'); 

    ... 
    $I->click('//*[@class="b"]/li[last()]/a'); // <<----- 
} 

그러면 페이지가로드됩니다. 나는 다른 방법이 전화를 이동하는 경우에는, 는 예를 들어, 논리적으로 적절한 여기서

public function tryToDoSomething(FunctionalTester $I) 
{ 
    $I->amOnPage('/site/login'); 
    ... 
    $I->cantSee('....', '.error-block'); 

    ...  
} 

public function TryToDoAnythingElse(FunctionalTester $I) 
{ 
    ... 
    $I->click('//*[@class="b"]/li[last()]/a'); // <<----- 
    ... 
} 

그럼, 얻을 다음과 같은 오류 :

Method Not Allowed (#405). This url can only handle the following request methods: . The above error occurred while the Web server was processing your request.

Please contact us if you think this is a server error. Thank you.

어떤 이유가 될 수 있을까? 나는 그 정보에 대해 매우 감사 할 것입니다. 모두에게 감사드립니다.

답변

0

해결책은 다음과 같습니다. 하나만 제외하고 모든 방법은 protected으로 표시되어 테스트로 실행되지 않습니다.

은 그 때 나는 "메인"시험 방법에서 호출 :

protected function tryToDoSomething(FunctionalTester $I) 
{ 
    $I->amOnPage('/site/login'); 
    ... 
    $I->cantSee('....', '.error-block'); 

    ...  
} 

public function tryToDoAnythingElse(FunctionalTester $I) 
{ 
    tryToDoSomething($I); 
    $I->click('//*[@class="b"]/li[last()]/a'); 
    ... 
} 

나는이 방법을 사용하는 경우, 오류가 발생하지 않습니다.

이어서 전체 시험 보호 메소드 호출들의 시퀀스로 표현 될 수있다 :

public function tryToGoThroughTheFlow(FunctionalTester $I) 
{ 
    $this->tryToA($I); 
    $this->tryToB($I); 
    $this->tryToC($I); 
    $this->tryToD($I); 
    ... 
} 

:

protected function tryToA(FunctionalTester $I) 
{ 
    ... 
} 

protected function tryToB(FunctionalTester $I) 
{ 
    ... 
} 

등등을. 오류의 원인은 분명하지 않지만 .. 허용되지 않는 유형의 요청을 보내고 있습니까?

+0

문제의 근본 원인을 알고 있습니까? 보호 된 메소드에 대한 호출과 관련하여, 주석을 "main"테스트 메소드에 추가하기 만하면됩니다. @before tryToA. – Andrew

+0

귀하의 의견에 진심으로 감사드립니다. 전혀 아닙니다 .. 의심 스럽지만 이것이 Cross-Origin Resource Sharing (CORS) 일 수 있으며 첫 번째 요청은 OPTIONS (허용되지 않음)입니다 ... –

+0

수용 테스트를 사용하더라도 동일한 문제에 직면하고 있습니다. 나는 WebDriver와 PhpBrowser를 시도했으며 두 번 모두 "method not allowed (# 405)"오류가 발생하면 "post"메서드를 사용하여 "delete"링크를 클릭합니다. – Andrew

관련 문제