Home ›
Filling in a textarea with multiple lines in a Behat testFilling in a textarea with multiple lines in a Behat test
Submitted by Benjamin Melançon on April 13, 2016 - 4:01am
Here's the syntax you're looking for:
And I fill in "Team" with: """ Lost dog Which army Runaround Sue """
This is possible with MinkContext::fillField(). MinkExtension is a standard part of Behat, and the fillField() method is the same one that processes steps in the form When I fill in "Fieldname" with "Value". The key is if the colon after the with is used, then the value can start on the next line, spanning multiple lines with the PyString syntax.
Here's the step definition as found with a behat -d "field"
for a project using the Behat DrupalExtension:
When /^(?:|I )fill in "(?P(?:[^"]|\\")*)" with:$/ | Fills in form field with specified id|name|label|value | Example: When I fill in "username" with: "bwayne" | Example: And I fill in "bwayne" for "username" | at `Drupal\DrupalExtension\Context\MinkContext::fillField()`
But as noted this is present in Behat's regular MinkExtension.
Searched words:
behat multiline text
behat multiline fields
behat enter into textarea a value spanning multiple lines
Comments
Post new comment