can I use innerNavigatorFactory approach to for navigator used by Form Control Modules?

41 views
Skip to first unread message

AlexB

unread,
Jun 11, 2019, 5:11:20 AM6/11/19
to Geb User Mailing List
Hi All,

As per the documentation I added to GebConfig class the following line:

innerNavigatorFactory = { Browser browser, List<WebElement> elements ->

   elements ? new MyCustomNavigator(browser, elements) : new EmptyNavigator(browser)

}


An I see MyCustomNavigator is used in all cases when elements are declared:
a) without using Form Control Modules
b) using CSS only as a locator.
Example:
static content ={
    anElement
{$("div>div>div.class>button")}
}

If I use geb locator syntax or specify a module for an element default NonEmptyNavigator is used.
Example:
static content ={
    anElement1
{$("div>div>div.class>button", text: "Continue")}
    anElement2
{$("div>div>div.class>button").module(FormElement)}
}

Question:
Is there a way to use MyCustomNavigator for the elements that use Form Control Modules as well?

AlexB

unread,
Jun 11, 2019, 5:13:26 AM6/11/19
to Geb User Mailing List
Oops. It looks like it works fine for Form Control Modules. Sorry. How do I delete this post?

Marcin Erdmann

unread,
Jun 11, 2019, 7:43:56 AM6/11/19
to geb-...@googlegroups.com
No problem Alex. There's no need to worry about deleting it, it still might prove useful to people and I don't think it's even possible to delete it.

Cheers,
Marcin

--
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/6de6ea18-6c84-436c-95b9-1e6d1fcd2d9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

AlexB

unread,
Jun 19, 2019, 5:21:42 AM6/19/19
to Geb User Mailing List
Hi again!

It looks like the question is valid. I found the case where MyCustomNavigator is not used. But it looks like the key point is not in the selector, but in the fact that elements from Modules do not use it.
Please see the attached screenshot.
The test failed due to StaleElementReferenceException. MyCustomNavigator has a workaround for it. But as per the exception the element does not use it.

Is there a Geb-natural way to make Module elements use MyCustomNavigator?

To unsubscribe from this group and stop receiving emails from it, send an email to geb-...@googlegroups.com.

AlexB

unread,
Jun 19, 2019, 5:23:52 AM6/19/19
to Geb User Mailing List
Here is the screenshot

NavigatorIssue.png

Marcin Erdmann

unread,
Jun 24, 2019, 5:43:37 PM6/24/19
to geb-...@googlegroups.com
Hi Alex,

The idea is that if you have configured a custom navigator to be used via a custom navigator factory then all instances of navigators, including the ones backing modules will be of your custom type. So if it's not the case then it will be a bug but I've looked at the code in depth and couldn't spot anything amiss. 

Can you please share your inner navigator factory and CustomNavigator implementations? A self contained, reproducible example would also be helpful - you could simply provide one based on geb.navigator.CustomNavigatorSpec in a fork of Geb's the repo.

Thanks,
Marcin

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.

Marcin Erdmann

unread,
Jun 25, 2019, 3:53:35 AM6/25/19
to geb-...@googlegroups.com
Thinking about it a bit more, are you by chance overriding $() in your custom navigator and not find()? You should always override find() and not $() because $() is an alias for find() and the crux of the implementation is in find() - $() just delegates to find().

AlexB

unread,
Jul 11, 2019, 1:58:33 PM7/11/19
to Geb User Mailing List
Hi Marcin,

I understood what's wrong here. I realized it while creating a small project as you asked. But now I think there is no need in it.

Here is the point:
I overrode click() method and expected it to wrap "Other element would receive the click" exceptions. And in some cases (where Form Control Modules were used) I still saw them. But it turned out that the issue is not in the click(). After closer analysis I found out that I get the exception ("Other element would receive the CLICK") when in fact I'm not clicking. I get the exception in lines like:
radioButton.checked = "value".
RadioButton module is not clicking when executing .checked() method. It sets a value, that is uses method .value(value). And this method was not overriden in my CustomNavigator. This is why I saw NonEmptyNavigator in stacktrace.

The behavior itself (throwing exception) looks reasonable. But the confusing thing is that I see "receive the click" in error message although I'm not in fact clicking.

Regards,
Alex


On Tuesday, June 25, 2019 at 10:53:35 AM UTC+3, Marcin Erdmann wrote:
Thinking about it a bit more, are you by chance overriding $() in your custom navigator and not find()? You should always override find() and not $() because $() is an alias for find() and the crux of the implementation is in find() - $() just delegates to find().

Reply all
Reply to author
Forward
0 new messages