phpbehatsahigoutte

How to select a driver in Behat?


I have both Goutte and Sahi installed. How do I know what driver I am using by default?

Also how do I change from one driver to the other?

Thank You

 public function iAmOnHomepage()
    {

      // $this->getSession()->visit("/");
   //     $driver = new \Behat\Mink\Driver\GoutteDriver();
    //    $session = new \Behat\Mink\Session($driver);

        // start session:
      //  $session->start();


     //   $this->getSession($session);
        $session = $this->getSession();
        $session->visit($this->locatePath('/'));

        $link = $session->getPage()->findLink('I am a Physician');

       if (null === $link) {
          throw new \LogicException("Home Page Not Loaded:\n");   
       }
    }

My behat.yml file:

default:
  formatter:
    name: progress
  extensions:
    Behat\Symfony2Extension\Extension:
      mink_driver: true
      kernel:
        env: test
        debug: true
    Behat\MinkExtension\Extension:
      sahi: ~
      goutte: ~
      base_url: 'http://local.referral.com'
      default_session: symfony2

Solution

  • you have to define "default_session: goutte" in your "Behat\MinkExtension\Extension" section. then define sahi_session: sahi

    now you will be able to switch session inside feature file like this:

    Feature: Category
      Add Category, change Category
    
      @sahi
      Scenario: Change Category, add new Category
      ....