You could probably simply do:
ids.each { $(id: it) << 'foo' }
and if you really need to go through content definitions then you can do:
ids.each { this."$it" = 'foo' }
or
ids.each { this[it] = 'foo' }
because form shortcuts are implemented using propertyMissing() on Page and
Module:
https://github.com/geb/geb/blob/9debdb8e7e425d3399a1e976bf18567866c4f9c8/module/geb-core/src/main/groovy/geb/content/PageContentSupport.groovy#L52
On Thu, Oct 19, 2017 at 4:19 AM, Samuel Rossinovic <
[email protected]> wrote:
> Actually, was thinking more along the lines of:
>
> def fillForm() {
> ids.each { /* it */ << 'foo' }
> }
>
>
>
> On Wednesday, October 18, 2017 at 5:29:21 PM UTC+11, Marcin Erdmann wrote:
>>
>> If you’re asking whether content defined in this dynamic way can be used
>> with form control shortcuts (used as target of assignements) then yes.
>> There is nothing special to content defined that way from Geb’s point of
>> view.
>>
>> On Wed, 18 Oct 2017 at 05:34, Samuel Rossinovic <[email protected]>
>> wrote:
>>
>>> Can templates declared in this method be used as targets of assignment
>>> (e.g. when their elements are form inputs)?
>>>
>>>
>>> On Sunday, October 15, 2017 at 12:24:22 AM UTC+11, Adam Gilbert wrote:
>>>>
>>>> That works perfectly! Thanks for the quick and correct response!
>>>>
>>>>
>>>> On Saturday, October 14, 2017 at 4:57:05 AM UTC-5, Marcin Erdmann wrote:
>>>>>
>>>>> Content defintions are method calls and not map entries. You should
>>>>> use the following:
>>>>>
>>>>> static def ids = ['header', 'title', 'element1', 'etc']
>>>>> static content = {
>>>>> ids.each { id ->
>>>>> "$id"({ $(id: id) })
>>>>> }
>>>>> }
>>>>>
>>>>> On Fri, Oct 13, 2017 at 5:32 PM, Adam Gilbert <[email protected]
>>>>> > wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> All the web elements I'm going to access have ID's, so I was hoping
>>>>>> to define the content using just a list of expected ID's.
>>>>>>
>>>>>> for example:
>>>>>> static def ids = ['header', 'title', 'element1', 'etc']
>>>>>> static content = {
>>>>>> ids.each {[it: {$(By.id(it))}]}
>>>>>> }
>>>>>>
>>>>>> However, it is unable to resolve any of them "as content or as a
>>>>>> property on its navigator context".
>>>>>>
>>>>>> How should I be defining content through a list?
>>>>>>
>>>>>> Thanks,
>>>>>> Adam
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Geb User Mailing List" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/geb-user/ee85325a-8e23-4ae
>>>>>> d-8270-9cfb69e134ce%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/geb-user/ee85325a-8e23-4aed-8270-9cfb69e134ce%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Geb User Mailing List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/geb-user/2b661852-cf71-4836-b607-caa3d289d609%40googlegroups.com
>>> <https://groups.google.com/d/msgid/geb-user/2b661852-cf71-4836-b607-caa3d289d609%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/geb-user/ac0151d3-dce6-4da7-8dda-9ee7c3adf403%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/ac0151d3-dce6-4da7-8dda-9ee7c3adf403%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "Geb
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/geb-user/CA%2B52dQTY0qeOTRBA8WVGBq-p_sJfyYzNNieAPnujuT8me64COQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.