16th September 2015

Behat Drupal extension region maps

John Ennew
Technical Director

Behat testing is awesome.

Sometimes you want to click a link which has nothing special to identify itself - e.g. the Edit link on a node page to edit the node.

You want to use this…

And I follow "Edit"

But get an error saying something about the link being hidden. Problem is the admin menu has edit links in it and these are not presently visible and its the first one which got found. What you want to say is

Click the link in the content bit of the page

Instead of writing custom step definition with regex of doom, use drupalextensions region_map function.

Use this step instead ...

And I follow "Edit" in the "tabs" region

Then you just have to tell behat how to find the ‘tabs’ region, which you do using a css selector in the behat.yml file

region_map: '.tabs'

More about it on this page:
http://behat-drupal-extension.readthedocs.org/en/latest/blackbox.html