Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing method handling. #239

geb-bot opened this issue Dec 3, 2012 · 4 comments

Missing method handling. #239

geb-bot opened this issue Dec 3, 2012 · 4 comments


Copy link

geb-bot commented Dec 3, 2012

Originally created by marko.m.

Please consider changing the behavior of empty-param missing method handling.

The expected behavior would be a missing method exception, but instead it surprisingly returns an empty element set.

Mailing list discussion:

Sample code:

class HomePage extends Page {
    static url = ""
} ChromeDriver()) {
    to HomePage

    // expecting to execute HomePage.foobar(), 
    // but instead is silently ignored?!?
Copy link

geb-bot commented Jan 6, 2013

Originally posted by marko.m.

After more list discussion with Marcin i understand that missingMethod delegates to a mixed-in Navigator of the current Page/Module context.

Polymorphic Navigator calls against Page/Module sound reasonable, so i don't want this request to sound like i'm pushing to break that.

My request specifically concerns the syntax of field shortcuts, which are handling Page/Module missingMethod/Property calls.

If an intended Page/Module method/property call has a syntax error, then it will be interpreted as an field lookup.

For that case, a syntax error can be very surprising and difficult to diagnose, particularly if the field does not exist (most likely case), since the result will be an empty Navigator.

** So in most cases, a Page/Module method/prop call syntax error results in no observable behavior.

What is the alternative?

One possible alternative is to disable the shortcut behavior of the internal Page/Module Navigator. Against an explicit Navigator all could behave as is, but method/prop calls against Pages/Modules would never result in field lookups.


// any field lookup directly against a Navigator could work as is.

// even shorter would be a lookup relative to the dom root/base of the current Page/Module.

// or a new syntax could be added that makes it explicit what the intent is. // ???

// but if a Page/Module method call failed, then an error would be reported immediately, rather than attempt to lookup an field.

Thank you.

Copy link

geb-bot commented Jan 2, 2014

Originally posted by Marcin Erdmann.

We could improve it the following way:

In my view the only thing we could do here is throw some kind of exception when there is no element with the given name on the page. The exception thrown should extend MissingMethodException and carry a message that we were looking for an element with the given name but didn't find it. This would remove the surprise factor but also slightly limit the functionality of the shortcut - it could be only used if the element with the given name is on the page. On the other hand it would keep the main functionality intact which I'm happy about. It will be also consistent with property shortcuts (like iDontExist = 'foo') failing fast with a MissingPropertyException.

Copy link

geb-bot commented May 10, 2014

Originally posted by Marcin Erdmann.

Thanks for being so persistent on this. In hindsight it's the only right thing to do in such situation. Fixing this also led to finding multiple places in the codebase where non existing methods were being called but they were not caught because of this.

Copy link

geb-bot commented Jun 12, 2014


@geb-bot geb-bot added this to the 0.9.3 milestone Apr 12, 2015
@geb-bot geb-bot closed this as completed Apr 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants