Selecting outside base from inside module/page

193 views
Skip to first unread message

cgmol...@gmail.com

unread,
Sep 16, 2015, 11:34:00 AM9/16/15
to Geb User Mailing List
How can I select elements relative to e.g. the DOM root inside a module with a base defined? For example, the popular select2 library generates <input> elements as children of <body> which are linked to the actual input controls in the HTML by auto-generated id's. So it could look something like this (angular pseudocode)

<body>
  <div>
    <..>
    <select2Control name="myInput" id="ctrl1">
      <button>Dropdown</button>
    </select2Control>
   </..>
  </div>
  <input id="ctrl1_search">
</body>

In this case the Geb module for the select2 control is based to "ctrl1" (since everything but the input interactions happen inside the control), but since the input is below <body> I have to break out of the "basing" to interact with it.


Kito Mann

unread,
Sep 16, 2015, 11:57:30 AM9/16/15
to geb-...@googlegroups.com
I'm not sure this is the best way, but I have been passing in the root Navigator instance when I create the module. I can then use that for content definitions that are outside of the module's base.
--
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+u...@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/6bde5b6a-38ef-48bd-8152-63aec5b35a7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
___

Kito D. Mann | @kito99 | Author, JSF in Action
Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and consulting
http://www.JSFCentral.com | @jsfcentral
+1 203-998-0403

* Listen to the Enterprise Java Newscast: http://enterprisejavanews.com
* JSFCentral Interviews Podcast: http://www.jsfcentral.com/resources/jsfcentralpodcasts/
* Sign up for the JSFCentral Newsletter: http://oi.vresp.com/?fid=ac048d0e17

Brian Kotek

unread,
Sep 16, 2015, 11:58:32 AM9/16/15
to Geb User Mailing List
Since Module is a Navigator, you should be able to do this just as you would with any other Navigator (using closest() or parents(), etc. to move back up the DOM hierarchy).

Marcin Erdmann

unread,
Sep 16, 2015, 1:19:55 PM9/16/15
to geb-...@googlegroups.com
Yeah, just use closest("body").
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/CAB06vMDXsLfp6pqEPfHp5kDGqLgcDTgSm1FFbBVS%2ByB4S2fjOw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages