Behat, Mink & Selenium: Open Website using Chrome Browser

Profile picture for user devraj

To launch website in chrome browser using Behat, Mink and Selenium follow below steps:

Step 1:  Add following code to behat.yml

chrome:
  extensions:
    Behat\MinkExtension\Extension:
      javascript_session: selenium2
      browser_name: chrome


Step 2: Add following code to FeatureContext.php or Your step definition file to launch website using chrome browser

$driver = new \Behat\Mink\Driver\Selenium2Driver('chrome');

$session = new \Behat\Mink\Session($driver);

$session->start();
$session->visit('http://automationpractice.com/');

Note:

  • Above code can be executed only when Feature file is already created.
  • Behat.yml file should be configured properly for below code. Above is just code snippet.
  • Before running the code start your selenium server with chrome first.