0

i'm am trying tu use Behat + Mink + Selenium2Driver into Symfony2.

  • i ran Selenium Server.
  • my behat.yml is:


    default:  
        extensions:  
            Behat\Symfony2Extension\Extension:  
                mink_driver: true  
            Behat\MinkExtension\Extension:  
                default_session: 'symfony2'  
                base_url: http://localhost/fhm_mind_solution/app_dev.php/  
                selenium2:  
                    wd_host: 'http://127.0.0.1:4444/wd/hub'  
                    capabilities: { "browser": "firefox", "version": "23"}

  • in my FeatureContext.php:


    class FeatureContext extends RawMinkContext  
                      implements KernelAwareInterface
    {
        private $kernel;
        private $parameters; 
        public function __construct(array $parameters)
        {
            $this->useContext('mink', new MinkContext);
        }     
    /* [...] */
          public function iCanAuthenticateAsAnAdmin()
      {
            $this->getSession();
      }

  • when i lauch Behat, i have always this: "could not open connection". What is missing?
nitche
  • 121
  • 3
  • 13

1 Answers1

1

Firstly, you didn't configure selenium driver properly. It should be:

default:  
    extensions:  
        Behat\Symfony2Extension\Extension:  
            mink_driver: true  
        Behat\MinkExtension\Extension:  
            default_session: 'symfony2'  
            base_url: http://localhost/fhm_mind_solution/app_dev.php/  
            selenium2:  
                wd_host: 'http://127.0.0.1:4444/wd/hub'  
                capabilities: { "browser": "firefox", "version": "23"}

Secondly, you don't have to initialize the driver nor the session yourself. It's done for you by the MinkExtension.

Simply make that your context extends the Behat\MinkExtension\Context\RawMinkContext and you'll get access to the $this->getSession() method.

Read more in the official docs: http://extensions.behat.org/mink/

You can see available capabilities in the selenium2 configuration: https://github.com/Behat/MinkExtension/blob/2.0/src/Behat/MinkExtension/services/sessions/selenium2.xml#L10

Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125
  • hi, on the first point: i already tryed that cnfiguration for behat.yml, but i have this error: [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException] Unrecognized options "wd_capabilities" under "behat.extensions.behat_minkexten sion_extension.selenium2" On the second point, can you give an example for the class definition? – nitche Sep 13 '13 at 11:52
  • That's because the parameter is called "capabilities". On the second point, read the friendly manual please (I've pasted the link to the docs where you can find it). – Jakub Zalas Sep 13 '13 at 11:57
  • One more thing - you need to install the selenium2 driver: https://packagist.org/packages/behat/mink-selenium2-driver – Jakub Zalas Sep 13 '13 at 12:47
  • is it this one: "behat/mink-selenium2-driver": "*@stable" in composer.json? then, it is installed. – nitche Sep 13 '13 at 12:50
  • i found out that the exception is catched here: https://github.com/Behat/MinkSelenium2Driver/blob/master/src/Behat/Mink/Driver/Selenium2Driver.php, at line 278. does it help? i don't know what to do... – nitche Sep 13 '13 at 15:10
  • Is your selenium server running on the same machine you're running behat? – Jakub Zalas Sep 13 '13 at 15:21
  • yes, it's the same machine, but i'm running it on Windows. today i will try on my Linux machine and i tell you then. – nitche Sep 16 '13 at 07:57