groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dinko Srkoč <dinko.sr...@gmail.com>
Subject Re: Call Method Without Params
Date Tue, 18 Aug 2015 08:55:10 GMT
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