I'm writting a Behat test, where I'm triying to create a content that uses a field address, generated by Address Module. I'm using Drupal 9.0.7, Address Module 1.9.0 and behat 3.8.1. My goal is to create this type of content in my scenario; I'm using a behat table for this, and a Given statement like the following.

Given place content:

  | title   | field_address:country_code |field_address:address_line1 | status |
  |<<title>>| es                         | Behat test street          | 1      |


field_address:country_code and field address:address_line1 are sub-fields of the address field.

This way of naming the sub-fields doesn't seeem to work.

How should I have to name the table headers, in order to make Behat create content with a field address properly filled?

  • Have you already tried it in a format like at the bottom of the opening post there: github.com/ymcatwincities/openy/pull/237#issue-111160763
    – leymannx
    Nov 18, 2020 at 15:23
  • | title | field_address:country_code | :address_line1 | status | maybe?
    – leymannx
    Nov 18, 2020 at 15:23
  • Yes, and it doesn't work. It gives me "Notice: Undefined offset: 0 in vendor/drupal/drupal-driver/src/Drupal/Driver/Fields/Drupal8/AddressHandler.php line 54". Nov 18, 2020 at 16:33
  • Is it maybe important, that there's a space between the pipe character and the field name? Because there the space is missing: |field_address:address_line1 and here as well: |<<title>>|. Is <<title>> some kind of placeholder or wildcard? And is this address field a multi-value field?
    – leymannx
    Nov 18, 2020 at 18:09
  • I don't think the space is important but I will try it to assure that that's not the case. And no, <<title>> it's not a wildcard. It doesn't matter here because title works properly,and when I post the question, I didn't pay attention to it, and place it as a wildcard to expess that it's not important. Sorry if Iconfuse you. I will try to put the spaces to see if it works. Thanks for your help!! Nov 19, 2020 at 8:11

1 Answer 1


I'm a bit late to the party but here is the proper way of doing it.

And "CONTENT_TYPE" content:
  | title          | field_address                    |
  | Bert and Ernie | address_line1: Sesame Street 123 |

The supported options are:

$addressFields = [

Which can be found in \Drupal\Driver\Fields\Drupal8\AddressHandler::expand

Currently there is a bug in drupal/drupal-driver so if you are using composer (which you should) you can apply the following patch. Otherwise you will get an error like "Notice: Undefined offset: 0"

"drupal/drupal-driver" : {
    "Issue #206: Address field in Drupal 8 (PR: 236/240)": "https://patch-diff.githubusercontent.com/raw/jhedstrom/DrupalDriver/pull/240.diff"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.