Question

I am facing an issue while trying to use Behat and mink within a symfony project (sf2.4).

Situation:

I just started to test behat for symfony2 projects, which looks like awesome. I would also be able to use mink, as my main projects are currently web projects. I therefore follow the tutorial of the official doc: official doc

Issue:

While testing "In browser" solution with selenium, I download the jar, start it, and run via another cmd line window:

php bin/behat features/search.feature

and there comes an error:

 [Behat\Testwork\ServiceContainer\Exception\ProcessingException]           
 The @javascript tag cannot be used without enabling a javascript session 

EDIT: featureContext.php looks like this

<?php
#features/FeatureContext.php

use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

use Behat\MinkExtension\Context\MinkContext;

/**
 * Behat context class.
*/
//class FeatureContext implements SnippetAcceptingContext
class FeatureContext extends MinkContext
{
    /**
     * Initializes context.
     *
     * Every scenario gets it's own context object.
     * You can also pass arbitrary arguments to the context constructor through behat.yml.
     */
    public function __construct()
    {
    }
}

Solution:

I am not too sure about 1) the meaning of this error (javascript session?) nor about 2) how to solve it. I wasn't able to get appropriate documentation on the web about causes and fix.

Any hint much appreciated!

EDIT2: Once this part was solved either by solving typo in #behat.yml, or by following doc for behat3 see jakub's post, which I was using at the time of this post), I had a second error:

Install MinkSelenium2Driver in order to use selenium2 driver.

This error was most evidently due to wrong composer setup. Just adding:

"behat/mink-selenium2-driver": "*"

solves this second issue. and it works!

Kind regards,

Was it helpful?

Solution

You need to do what the message tells you to do and configure the javascript session ;)

default:
  suites:
    first:
      mink_session: default
      mink_javascript_session: selenium2
  extensions:
    Behat\MinkExtension:
      base_url:  'http://example.com'
      sessions:
        default:
          goutte: ~
        selenium2:
          selenium2: ~

You're reading the docs from Behat v2 but you're using Behat v3.

Docs for v3 are not on behat.org just yet. For now, read them here: http://behat.readthedocs.org/en/latest/

For MinkExtension go here: https://github.com/Behat/MinkExtension/blob/master/doc/index.rst

Docs should be published to behat.org soon (hopefuly).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top