Hi Jose,
I would use a module instead of a custom navigator, because it's easier to
implement a module than dealing with a custom navigator factory and module
is-a navigator (
http://www.gebish.org/manual/current/#code-module-code-is-a-code-navigator-code).
I can't spot a difference between your Bootstrap and Zurb controls so I
will only give example for one of them:
class BootstrapSelectModule extends Module implements Selectable {
void select(String value) {
browser.js.exec(firstElement(), value, "...")
}
}
and then:
static content = {
bootstrapDropdown { $("#jqueryDropdown").module(BootstrapSelectModule)
}
}
What's more, instead of having a custom select() method, you could override
value() and value(Object) methods (i.e.
http://www.gebish.org/manual/current/api/geb/navigator/Navigator.html#value()
and
http://www.gebish.org/manual/current/api/geb/navigator/Navigator.html#value(def))
which will create a more idiomatically Geb API for your module.
Hope this helps,
Marcin
On Mon, Jul 4, 2016 at 4:59 PM, Jose Badeau <[email protected]> wrote:
> Given the following markup:
>
> <div id="bootstrapDropdown" class="dropdown">
> <button class="btn btn-default dropdown-toggle" type="button"
> id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true"
> aria-expanded="true">
> Dropdown
> <span class="caret"></span>
> </button>
> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
> <li><a href="#">Item 1</a></li>
> <li><a href="#">Item 2</a></li>
> <li><a href="#">Item 3</a></li>
> <li><a href="#">Item 4</a></li>
> </ul>
> </div>
>
> <ul id="zurbDropdown" class="dropdown menu" data-dropdown-menu>
> <li><a href="#">Item 1</a></li>
> <li><a href="#">Item 2</a></li>
> <li><a href="#">Item 3</a></li>
> <li><a href="#">Item 4</a></li>
> </ul>
> and the following page content
>
> static content = {
> bootstrapDropdown(wait: true) { $("#bootstrapDropdown") }
> zurbDropdown(wait: true) { $("#zurbDropdown") }`
> }
> I would like to be able to select an item like:
>
> bootstrapDropdown.select("Item 2")
> zurbDropdown.select("Item 2")
> I would like to have 2 custom navigators
>
> BootstrapNavigator implements Selectable {
>
> void select(String value) {
> browser.js.exec(firstElement(), value, "...")
> }
> }
> ZurbNavigator implements Selectable {
>
> void select(String value) {
> browser.js.exec(firstElement(), value, "...")
> }
> }
> The innerNavigatorFactory could be used I suppose but something like:
>
> static content = {
> bootstrapDropdown(wait: true) { $bootstrap("#jqueryDropdown") }
> zurbDropdown(wait: true) { $zurb("#zurbDropdown") }`
> }
> Would be nice. I would like to write geb navigators for different widget
> toolkits but using the same interfaces. Do you see a clean way to do this?
>
> --
> 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/f5722893-c62b-48de-86c0-b7ab6329edf8%40googlegroups.com
> .
> 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%2B52dQQrC7AXXrfKMkt_oy0-DWJY5Lyh6dxGPJa3NEXmw%2B%2BMig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.