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 10:45:01 GMT
My bad. Looks like intellij using old compiled .class. Removing out
directory and then running works smooth.

Thanks for your help.
On 18 Aug 2015 11:52, "Dinko Srkoč" <dinko.srkoc@gmail.com> wrote:

> On 18 August 2015 at 11:44, Anto Aravinth <anto.aravinth.cse@gmail.com>
> wrote:
> > No I'm sure they are same. That wasn't an typo. Wondering why does groovy
> > not picking them.
>
> So, how does the relevant code look like?
>
> If the code had worked before, but gave "unexpected token: ..." error
> after removing parens, it should have worked after renaming method
> from `TestBehavior` to `testBehavior`, given all else stayed the same.
>
> >
> > On 18 Aug 2015 10:55, "Dinko Srkoč" <dinko.srkoc@gmail.com> wrote:
> >>
> >> On 18 August 2015 at 10:45, Anto Aravinth <anto.aravinth.cse@gmail.com>
> >> wrote:
> >> > 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?
> >>
> >> My guess would be that there's a typo or that you changed the method
> >> name in one place and forgot to do it in another.
> >>
> >> Try checking the declaration site (SeleniumCallHandler) and the call
> >> site (loadPageGroovy.groovy) whether the method you call is the same
> >> you declared (I guess it should be `testBehavior` in both cases).
> >>
> >> Cheers,
> >> Dinko
> >>
> >> >
> >> > 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