Behat Launch Microsoft Edge Browser using Mink Selenium2Driver

Profile picture for user devraj

To launch Microsoft Edge browser using Selenium2Driver follow below steps:

Step 1: Make sure Selenium2Driver is installed using Composer, you can check your composer file for that. Otherwise execute below command.

$ composer require --dev behat/mink-selenium2-driver

Step 2: Download Selenium Server from Here, click on latest stable version. I am using version 3.5.3

Step 3: Check you browser version. Download Edge browser compatible with your browser and OS from Here.

Step 4: Run below command in the directory where you have downloaded your server and edge file otherwise you can give the path of directory. For me both files are in same directory.

Note: In case you are facing issue with latest version try to download previous version of server from here

Version 4+ would require different configuration and version less than 4 and greater 3.5.3 is throwing refection class error. I would recommend using version 3.5.3. 

$ java -jar -Dwebdriver.edge.driver=msedgedriver.exe selenium-server-standalone-3.5.3.jar

Step 5: Make sure your behat.yml is configure properly. Selenium2 driver is enabled, default session is set and browser name is added. Here is my behat.yml with profile for edge driver.

#behat.yml
default:
  suites:
    default:
      paths:
        features: features
        bootstrap: 'features/bootstrap'
      contexts:
        - FeatureContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2:
        wd_host: http://127.0.0.1:4444/wd/hub
      default_session: selenium2
      base_url: https://www.programsbuzz.com

edge:
  extensions:
    Behat\MinkExtension:
      browser_name: MicrosoftEdge
      selenium2:
        capabilities:
          extra_capabilities:
            edgeOptions:
              args:
                - "--start-fullscreen"
              w3c: false

Step 6: Add following step to feature file.

#language: en
@login
Feature:Test Ask Doubt Functionality

  Background:
    Given I am on homepage
  @P1
  Scenario: Test Ask Doubt
    When I click on ask doubt button

Step 7: Add step definition for ask doubt

    /**
     * @When I click on ask doubt button
     */
    public function iClickOnAskDoubtLink()
    {
        $page = $this->getSession()->getPage();
        $page->find('css', "a[href='/ask-doubt']")->click();
        sleep(5);
    }

Step 8: Execute using below command. Path might be different for you.

$ bin\behat -p edge --tags @P1
Tags