2016-07-11 8 views
1

일반적으로 새 탭에서 URL을 여는 버튼을 클릭하는 behat 테스트가 있습니다.새 탭이 behat과 mink로 열려 있습니다. PHP

버튼을 클릭 한 후 새 탭이 열렸는지 테스트 할 수 있습니까?

Scenario: Open document in a new tab 
    Given I am a "Project Admin" for project "x" 
    And Project "x" has document type "orbitron" with editor "none" 
    And I create a new orbeon form "orbitron" for project "x" from fixture "OrbitronFilePicker.xhtml" 
    Then I visit the orbeon new content form for document type "orbitron" in project "x" 
    And I can see the "file-picker" control 
    When I enter a valid file picker reference "urn:isite:x:mickeyMouse" 
    Then I can see the card with "mickeyMouse" header 
    When I click "Open In New Tab" in the Dropdown Action Menu for "#section-1-control≡xf-383" 
    Then The document should open in a new tab 
+0

th로 전환 할 방법/단계를 사용하려 했습니까? 새로운 창? switchToWindow가 호출됩니다. – lauda

+0

아직 havent 없습니다. switchToWindow를 살펴 보겠습니다. (BDD의 새로운 기능입니다) – chinds

답변

3

당신이 뭔가를 시도 할 수 있습니다 :

은 작은 오이입니다

/** 
* @When /^The document should open in a new tab$/ 
*/  
public function documentShouldOpenInNewTab() 
{ 
    $session  = $this->getSession(); 
    $windowNames = $session->getWindowNames(); 
    if(sizeof($windowNames) < 2){ 
     throw new \ErrorException("Expected to see at least 2 windows opened"); 
    } 

    //You can even switch to that window 
    $session->switchToWindow($windowNames[1]); 
} 

참고 :은 아마 창문이 일부 지연 열 수 있으며,이 경우 당신은 기다릴 필요 그것 :

$ttw  = 40; 
    while ((sizeof($session->getWindowNames()) < 2 && $ttw > 0) == true) { 
     $session->wait(1000); 
     $ttw--; 
    }