groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anto Aravinth <anto.aravinth....@gmail.com>
Subject Re: Call Method Without Params
Date Tue, 18 Aug 2015 08:45:38 GMT
Oh thanks. But changing my method name to start with small letter compiles
and works. But it gives methodMissingException.

Really not sure where the issue is. Any guesses?
On 18 Aug 2015 09:15, "Dinko Srko─Ź" <dinko.srkoc@gmail.com> wrote:

> On 18 August 2015 at 07:10, Anto Aravinth <anto.aravinth.cse@gmail.com>
> wrote:
> > [...]
> > loadGroovyPage.groovy:
> >
> > TestBehavior('test google home page' , {
> >
> >     loAd "http://www.google.com"
> >
> >     driver.findElement(By.id("lst-ib")).sendKeys("Selenium!")
> >
> > })
> >
> > the TestBehavior method is defined in SeleniumCallHandler. Like:
> >
> >     def TestBehavior(def name,Closure cls)
> >
> >     {
> >
> >         cls.delegate = this;
> >
> >         cls();
> >
> >     }
> >
> > The above code in loadGroovypage works fine. But to make my DSL good, I
> > tried this:
> >
> > TestBehavior 'test google home page' , {
> >
> >     loAd "http://www.google.com"
> >
> >     driver.findElement(By.id("lst-ib")).sendKeys("Selenium!")
> >
> > }
> >
> > (same code without param's) And this code fails with message:
> >
> > Error:(1, 13) Groovyc: unexpected token: test google home page on
> > loadGroovyPage.groovy.
> >
> > Where I'm making the mistake? Does the method call without params should
> > work without any issues right?
>
> The problem is with method's name, i.e. it starts with a capital
> letter. If the method's name had been `testBehavior`, it would have
> worked fine.
>
> I may not be the most suitable person to explain this, but here it is
> ... Generally, a name starting with a capital letter is considered a
> class. Having `Foo(arg1, arg2)` is not ambiguous, so you got away with
> it. On the other hand, `Foo arg1, arg2` is, hence the error.
>
> Cheers,
> Dinko
>
> >
> > Thanks,
> > Anto.
>

Mime
View raw message