Skip to main content

Behat Drupal Extension Map Region using Blackbox Driver

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

Submitted by tgoswami on November 13, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.