2013-06-14 4 views
1

Symfony 프로젝트에서 작업 중이며 Behat/Mink로 단위 테스트를 만들고 싶습니다. 내 FeatureContext 클래스에서 마지막 행을 정의Behat : switchToIFrame()을 사용하여 오류가 발생했습니다.

Feature: Homepage 
Scenario: Check if I can log on 
    Given I am on "/" 
    And I follow "connexion_js" 
    And I switch to the iframe "cboxIframe" 

:

나는 시나리오를 가지고있다.

class FeatureContext extends MinkContext implements KernelAwareInterface{ 

    // ... 

    /** 
    * @Given /^I switch to the iframe "([^"]*)"$/ 
    */ 
    public function iSwitchToIframe($arg1 = null) 
    { 
     $this->getSession()->switchToIFrame($arg1); 
    } 
} 

내 쉘 명령을 실행할 때 :

$: bin/behat "@PoleMainBundle" 
Feature: Homepage 
Scenario: Check if I can log on   # src/xxx/xxx/MainBundle/Features/homepage.feature:2 
Given I am on "/"      # xxx\xxx\MainBundle\Features\Context\FeatureContext::visit() 
And I follow "connexion_js"   # xxx\xxx\MainBundle\Features\Context\FeatureContext::clickLink() 
And I switch to the iframe "cboxIframe"  # xxx\xxx\MainBundle\Features\Context\FeatureContext::iSwithToIframe() 
    iFrame management is not supported by Behat\Symfony2Extension\Driver\KernelDriver 
... 

답변

1

많은 시도 후, 나는 답을 찾을 수 있습니다. 모든 behat 함수에 대해 메서드는 모든 유형의 인수 (id, class, name, ...)를 넣을 수 있습니다.

switchToIFrame() 메서드의 경우 메서드는 요소의 NAME !!!

더 많은 경우 Behat/Mink에서만이 방법을 사용할 수 없었습니다.

저는 Selenium2 서버를 사용하고 파일 .feature에 '@javascript'를 추가했습니다.

Feature: Homepage 
    @javascript 
    Scenario: Check if I can log on 
    Given I am on "/" 
    ... 

작동합니다!