Behat Drupal Extension Map Region using Blackbox Driver

Profile picture for user devraj

In this tutorial we will discuss how to map region using Behat Drupal Extension Blackbox driver. Here is our behat.yml file where we have mapped the region for our umami food magazine website. To map region first we need to identify the region on our website:

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Drupal\MinkExtension:
      goutte: ~
      selenium2: ~
      base_url: http://bdrupal.dd:8083
    Drupal\DrupalExtension:
      blackbox: ~
      region_map:
        footer: ".footer"
        header: ".layout-header"

This is our feature which is using different region:

Feature: Testing the region
  Scenario: test links in region
    Given I am on the homepage
    When I follow "Article" in the "header" region
    Then I should see "Give it a go and grow your own herbs"
    When I follow "Contact" in the "footer" region
    Then I should see "Website feedback"

You can change link and region to incorrect value to experiment. Here after following Article link in header we are asserting some text and following contact link in footer section asserting another text "Website Feedback." 

Tags