I need to upload an image to a term as well as to a node using BEHAT with Drupal API. How this can be possible?

1 Answer 1


You need to define a Behat step for it. A possible way would be to define a method to be executed before creating a node (labelled with @beforeNodeCreate), to upload the file first and then to attach its fid to the appropriate file field of the node or term.

A possible way of doing it (for Drupal 8) is explained in detail here: https://webscope.co.nz/testing-image-and-file-fields-with-behat

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.