Closed (won't fix)
Project:
Behat Drupal Extension
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2013 at 12:00 UTC
Updated:
5 Mar 2026 at 11:41 UTC
Jump to comment: Most recent
I saw this post on the Behat group on g.d.o:
https://groups.drupal.org/node/381608
Which had some steps for checking the visibility of form elements:
https://gist.github.com/pbuyle/7698675
These would be super useful in the Behat Drupal extension!
The original author uses them for testing '#states' and I've personally needed something similar for making sure that each role only has access to the form elements they should on entity edit forms.
Would you consider accepting this? If so, I'll write a patch for you to review. I just wanted to see if there was interest first - I don't know what your policy is on accepting new steps that aren't completely Drupal-related.
Thanks!
Comments
Comment #1
pbuyle commentedIMHO, for my steps to be included into the extension they would need more work. They currently heavily rely on, what I think is, the default Drupal form markup and have only been tested in a single custon theme. The code to retrieve a form element or its label should abstracted to easily overwriteable methods. One of these methods should be used to retrieve the form labels on the page. Once you have a form label element, you can retrieve its form element using its
forattribute (requiring this attribute is a reasonable requirments). Another method should be used to retrieve the type (ie. the Drupal form API#type) of a form element.Comment #2
fgmHi @mongolito404. Thanks for the steps. Until they are committed to d.o., they are just available as a Gist without any licensing info, theoretically preventing anyone from using them, which is probably not what you want.... but the Github terms of service do not specify any fallback license when none is specified :-(
Would you mind updating the gist to include a licensing clause, preferably compatible with Drupal, like : "This code is released under the GNU General Public License version 2 or later", just like Drupal itself.
This might encourage reuse and updates, likely as a patch on this issue.
Comment #3
pbuyle commentedHi, I added a LICENSE file to the Gist. The code is now distributed under a MIT-style licence. The licence is compatible with the GPL v2. In addition to this licence, if the code is included in a software distributed on drupal.org, the copyright notice may be removed.
Comment #4
jhedstromI've linked this Gist in the README and on the project page. Thanks!
Marking postponed for now, if it gets generalized as a patch, please re-open for consideration.
Comment #5
alex.skrypnykhttps://github.com/drevops/behat-steps/blob/main/src/ElementTrait.php#L305