You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AePageObjects::Form and the DSL method form_for() are used like so:
form_for:logindoelement:emailelement:passwordend
This is similar to using the element DSL method, like so:
element:logindoelement:emailelement:passwordend
_The Differences_
Form vs Element
Form does not have a default_locator. When accessing a form instance, the underlying node is the same as the parent's node. This means there doesn't need to be a <form> element on the page at all.
form_for() vs element() form_for is the same as element except:
it does not accept an :is option.
it creates delegated accessors on the parent Element for the elements defined on the Form. For example, in the usage above, the following is supported:
# access email explicitly through the formsome_page.login.email# access email through the delegated accessorsome_page.email
Usually in these cases, the user is not interested in representing a form element in the page object. That's to say that either the user wants elements to be nested under an explicit element (like the login element defined above) or the user wants the elements to be defined on the parent element and using form_for to leverage the structural nesting to get the right default locator for the contained elements.
For example, using Rails, consider the case that the input fields to the login form are named "user[email]" and "user[password]". To achieve this, the user needs to specify "user" as the name of the form element via:
The user doesn't care about representing the underlying form element through the page object interface, she is just using form_for to manipulate the name used by the default locator for the nested elements.
_The Proposal_
The features intertwined within Form and form_for should be generally and independently available for the definition of any element.
Enhance element DSL an option to reflect accessors
The element DSL should support an option to create delegates on the parent element to the elements of the element being defined.
AePageObjects::Form
and the DSL methodform_for()
are used like so:This is similar to using the
element
DSL method, like so:_The Differences_
Form vs Element
Form does not have a default_locator. When accessing a form instance, the underlying node is the same as the parent's node. This means there doesn't need to be a
<form>
element on the page at all.form_for() vs element()
form_for
is the same aselement
except::is
option.Usually in these cases, the user is not interested in representing a form element in the page object. That's to say that either the user wants elements to be nested under an explicit element (like the login element defined above) or the user wants the elements to be defined on the parent element and using
form_for
to leverage the structural nesting to get the right default locator for the contained elements.For example, using Rails, consider the case that the input fields to the login form are named "user[email]" and "user[password]". To achieve this, the user needs to specify "user" as the name of the form element via:
or:
The user doesn't care about representing the underlying form element through the page object interface, she is just using
form_for
to manipulate the name used by the default locator for the nested elements._The Proposal_
The features intertwined within
Form
andform_for
should be generally and independently available for the definition of any element.Non-scoped elements
#88
Enhance element DSL an option to reflect accessors
The
element
DSL should support an option to create delegates on the parent element to the elements of the element being defined.Perhaps:
Provide mechanism for manipulating default locator
#89
_Deprecation_
Form
andform_for
could be implemented with the above features.Exact equivalent:
Don't represent form on parent element:
Represent form on parent element:
The text was updated successfully, but these errors were encountered: