content template inaccessible on module

38 views
Skip to first unread message

Samuel Rossinovic

unread,
Aug 16, 2017, 8:36:14 AM8/16/17
to Geb User Mailing List
A page contains a list of checkboxes:

<ul>
 
<li>
 
<div class="tree-node">
 
<span class="tree-checkbox tree-checkbox1"></span>
 
<span class="tree-title">foo</span>
 
</div>
 
</li>
 
<li>
 
<div class="tree-node">
 
<span class="tree-checkbox tree-checkbox0"></span>
 
<span class="tree-title">bar</span>
 
</div>
 
</li>
<ul>


Where .tree-checkbox1 renders a checked box, and .tree-checkbox0 renders an unchecked one. In the above sample, foo is checked, and bar isn't.

I've written this module to interact with the checkbox entries:

class CheckboxItem extends Module {
 
static content = {
 label
{ $(".tree-title").text() }
 checkbox
{ $(".tree-checkbox") }
 isChecked
{ checkbox.hasClass "tree-checkbox1" }
 
}
}

When I create an CheckboxItem object, I find I can access its label content, as well as checkbox, but attempting to access isChecked yields:

groovy.lang.MissingPropertyException: Unable to resolve isChecked as content for CheckboxItem, or as a property on its Navigator context. Is isChecked a class you forgot to import?



Help?

Marcin Erdmann

unread,
Aug 17, 2017, 3:30:52 AM8/17/17
to Geb User Mailing List
I suspect it's because an "is" can be used as a method prefix for boolean getters in Groovy (same way as "get" can be used as prefix for any getter) so the content is actually visible under "checked" and not "isChecked". Try changing the content name or accessing it using "checked" instead of "isChecked".

--
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 geb-user+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/a0f792ea-bedb-4786-b64f-49194eb1bbff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samuel Rossinovic

unread,
Aug 17, 2017, 7:29:58 AM8/17/17
to Geb User Mailing List
Changed content template to "checked". Changed call to ".checked", but to no avail.

A side (but important) note: I'm getting the failure when attempting to use geb through an interactive console (intellij idea / groovy console). The motivation for this is to be able to trial stuff, w/o the overhead of re-running a test every time I change something. My experience so-far is that that testing is quite unstable, and results may differ from an actual test. 

So the point I'm driving at: would be good to consolidate a set of instructions on how to correctly use geb in an interactive session. I've found some stuff on the web that I couldn't get to work, and am currently having limited success with the below.

Here's what I paste into the console:

import geb.Browser
//rest of my imports here
Browser.drive {
   
//some geb stuff I wish to test
}
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.

Marcin Erdmann

unread,
Aug 18, 2017, 3:03:52 AM8/18/17
to geb-...@googlegroups.com
There are some issues around closure delegation that I do not believe are fixable when using Browser.drive {} but I do not think this is related to your issue.

Can you please change the name of the content name to something random like foo (could checked have special meaning in the context of the code you're executing?)? And if that doesn't work paste more code that shows what you're doing? Maybe you're doing something different between acessing the label and checked content you are not telling us about? Being able to see a bit more of your stacktrace wouldn't hurt either. :)

Reply all
Reply to author
Forward
0 new messages