Baptiste Donaux
Baptiste Donaux

Reputation: 1310

Behat : Error using switchToIFrame()

I am working on a Symfony project and I want to create unit test with Behat/Mink.

I have a scenario :

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"

I have defined the last row in my FeatureContext class.

class FeatureContext extends MinkContext implements KernelAwareInterface{

    // ...

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

When I execute my shell command :

$: 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
...

Upvotes: 1

Views: 1776

Answers (1)

Baptiste Donaux
Baptiste Donaux

Reputation: 1310

After many try, I have find the answer. For any behat's functions, the methods can put any types of arguments (id, class, name, ...).

For the method switchToIFrame(), the method put only the element's NAME !!!

In more, I have not been able to use the method with only Behat/Mink.

I use now Selenium2 server and I added '@javascript' in my file.feature.

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

It works !

Upvotes: 1

Related Questions