Question

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
Was it helpful?

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

OTHER TIPS

I wanted to be able to switch between methods from the CLI when developing.

  • Assume goutte most of the time (unless the test itself was tagged to prefer @javascript)
  • BUT to see where problems were, I wanted to see even the non-js ones in action on my screen.

My behat.yml:

default:
  suites:
    default:
      paths:
        - %paths.base%/features
      contexts:
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2: ~

chrome:
  extensions:
    Behat\MinkExtension:
      browser_name: chrome
      default_session: 'selenium2'

Now, running 'behat' will use goutte mostly, but if I choose to run

behat -p chrome

I get the browser version of the same things running.

behat version 3.1.0 (I saw many docs saying it was "Behat\MinkExtension\Extension" - but I found it was "Behat\MinkExtension" - this may be a version thing.)

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