@@ -36,6 +36,7 @@ be used in automated acceptance test suites.
3636 - [ Custom Elements] ( #custom-elements )
3737 - [ Forms] ( #forms )
3838 - [ Collections] ( #collections )
39+ - [ Custom Collections] ( #custom-collections )
3940 - [ Staling] ( #staling )
4041 - [ Load Ensuring] ( #load-ensuring-1 )
4142 - [ Checking presence] ( #checking-presence )
@@ -939,7 +940,13 @@ class AuthorsNewPage < AePageObjects::Document
939940end
940941```
941942
942- Additionally, if you can use ` :is ` to specify the collection type:
943+
944+ #### Custom Collections
945+
946+ Sometimes, we'll want a collection that supports more methods
947+ than what the [ default implementation] ( ./lib/ae_page_objects/elements/collection.rb )
948+ supports. An easy way to handle this use case is to create a new
949+ class that inherits from ` AePageObjects::Collection ` :
943950
944951``` ruby
945952class Address < AePageObjects ::Element
@@ -952,15 +959,21 @@ class AddressList < AePageObjects::Collection
952959 last.click(' .delete-button' )
953960 end
954961end
962+ ```
963+
964+ Then, in the page object, use ` :is ` to specify the collection type:
955965
966+ ``` ruby
956967class AuthorsNewPage < AePageObjects ::Document
957968 form_for :author do
958969 collection :addresses , is: AddressList , contains: Address
959970 end
960971end
961972```
962973
963- ` collection ` supports every combination of ` :is ` , ` :contains ` , and the block. See the source for more examples.
974+ This custom collection is also declared to contain items of the custom
975+ ` Address ` element subclass. ` collection ` supports every combination of
976+ ` :is ` , ` :contains ` , and the block. See the source for more examples.
964977
965978### Staling
966979
0 commit comments