minkphp / MinkSelenium2Driver

Selenium2 (webdriver) driver for Mink framework
MIT License
507 stars 163 forks source link

How should I implement MinkSelenium2Driver in a Behat configuration? #281

Closed Drillan767 closed 6 years ago

Drillan767 commented 6 years ago

Hello, this might be pretty simple but I can't manage to correctly implement MinkSelenium2Driver in a Behat configuration.

I actually need it in a way bigger project, but I created a small / simple project so that I have the control on everything without breaking anything.

Here is my behat.yml file:

default:
  suites:
    default:
      contexts:
        - Behat\Mink\Driver\Selenium2Driver
  gherkin:
     cache: ~
  extensions:
    Behat\MinkExtension:
      browser_name: chrome
      base_url: http://www.website.net
      sessions:
        default:
          goutte: ~
        javascript:
          selenium2: ~

Here is my FeatureContext file:

<?php

use Behat\MinkExtension\Context\MinkContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends MinkContext {

  /**
   * FeatureContext constructor.
   */
    public function __construct()
    {
    }
}

And here is my dummy feature file:

Feature: Dummy test

    Scenario: Test some stuff idk
        Given I am on the homepage
        Then I should see "Login"

Without adding the - Behat\Mink\Driver\Selenium2Driver line to the behat file, everything works. However, adding it returns the following error:

Every context class must implement Behat Context interface, but Behat\Mink\Driver\Selenium2Driver does not.

And since your example is pretty much outdated, I can't find any good example

So my question is: how can I implement it correctly?

Thank you in advance

stof commented 6 years ago

Behat\Mink\Driver\Selenium2Driver is not a Behat context at all. what you need in your contexts configuration is your FeatureContext class

Drillan767 commented 6 years ago

Soooo... I made it work, I don't know how, but I just made sure that composer.json required the MinkSelenium2Driver, I added @javascript to my test, removed everything related to the driver from my FeatureContext and... it worked. I can't figure out how nor why but it works. So, thank you I guess, I can close this :')