The $() function

Skip to first unread message

Michael Schaefer

Apr 23, 2016, 10:19:28 AM4/23/16
to Geb Development Mailing List
Hello Devs, 

First, kudos on a great Groovy project. I pulled the code. I'm learning a lot from what you've built here. I have a couple of quick questions:

1. Would any of your code work with XML with no server? I'd like to parse an XML document, create a DOM and then be able to use the $() function to get back a Navigator object and walk the DOM that way. That possible?

2. If that's not possible, I'd like to write it. Basically I'd like to implement what the Node.js guys have with the Cheerio library, but in Groovy. Can you point me to where you implemented the $() function? I pulled the project into IntelliJ, but as you can imagine, there are literally thousands of instances of $ in the code.  :)

Thanks in advance for any help you can give.


Marcin Erdmann

Apr 25, 2016, 1:23:43 PM4/25/16
I'm on holidays atm, will respond next week.

You received this message because you are subscribed to the Google Groups "Geb Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

Marcin Erdmann

May 5, 2016, 4:36:41 PM5/5/16
Hi Michael,

Sorry for the late response, hopefully it's still relevant.

1. No, Geb is designed to drive browsers which consume html content and therefore is not a good fit for parsing XML and using the $() method to walk the result. There are libraries that are better at that, though:
- JSoup can parse xml ( and allows to use css selectors for navigation
- Jerry is a similar library and it looks like it also supports parsing XML:

2. The implementation of the $() method is not straightforward and the element lookup itself is delegated to WebDriver's SearchContext in SearchContextBasedBasicLocator. Anyway, given JSoup and Jerry you would be reinventing the wheel by implementing an equivalent of Cheerio, I'm affraid.
Reply all
Reply to author
0 new messages