ae_page_objects
                                
                                 ae_page_objects copied to clipboard
                                
                                    ae_page_objects copied to clipboard
                            
                            
                            
                        Remove Form and form_for()
AePageObjects::Form and the DSL method form_for() are used like so:
form_for :login do
  element :email
  element :password
end
This is similar to using the element DSL method, like so:
element :login do
  element :email
  element :password
end
_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 :isoption.
- 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 form
some_page.login.email
# access email through the delegated accessor
some_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:
form_for :login, name: "user" do
  element :email
  element :password
end
or:
form_for :user do
  element :email
  element :password
end
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.
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:
element :login, reflect_elements: true do
  element :email
  element :password
end
Provide mechanism for manipulating default locator #89
_Deprecation_
Form and form_for could be implemented with the above features.
Exact equivalent:
element :login, name: "user", reflect_elements: true, locator: :parent do
  element :email
  element :password
end
Don't represent form on parent element:
with_name "user" do
  element :email
  element :password
end
Represent form on parent element:
element :login, name: "user",  locator: :parent do
  element :email
  element :password
end