using connectUrl without extending any of the class

1 view
Skip to first unread message

Haroon Rasheed

unread,
Feb 10, 2011, 12:53:35 PM2/10/11
to tellurium-...@googlegroups.com
Hi,

I have following code which is giving me a Null pointer exception.

 TelluriumGroovyTestCase.newInstance().with {
        connectUrl "http://www.google.com"
    }

I want to call connectUrl method without extending any of the Tellurium classes, how would I do that??

Thanks
Haroon

Jian Fang

unread,
Feb 10, 2011, 12:58:05 PM2/10/11
to tellurium-...@googlegroups.com
You can try to add connectSeleniumServer to the TelluriumGroovyTestCase constructor.

--
You received this message because you are subscribed to the Google Groups "tellurium-developers" group.
To post to this group, send email to tellurium-...@googlegroups.com.
To unsubscribe from this group, send email to tellurium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tellurium-developers?hl=en.

Haroon Rasheed

unread,
Feb 10, 2011, 1:09:42 PM2/10/11
to tellurium-...@googlegroups.com
I dont want to change the code, I am trying to write a Cucumber style Tellurium test. The source code is as follows. 


package test

import module.GoogleSearchModule
import org.tellurium.test.groovy.TelluriumGroovyTestCase


this.metaClass.mixin(cuke4duke.GroovyDsl)

GoogleSearchModule gsm;

Given (~/The search is Hello World/){
    gsm = new GoogleSearchModule();
    gsm.defineUi();
   TelluriumGroovyTestCase.newInstance().with {
        connectUrl "http://www.google.com"
    }
}

When (~/The Search is performed/){
    gsm.doGoogleSearch "Hello World"
}

Then (~/The browser title should have Hello World/){
    assertEquals gsm.getBrowserTitle(),"Hello World"
}

and when it runs I get the following error. 

   Given The search is Hello World                # test.GoogleSearchFeature$_run_closure1@15e565bd
[INFO]       org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NullPointerException: Cannot invoke method connectUrl() on null object (NativeException)
[INFO]       org/codehaus/groovy/reflection/CachedMethod.java:92:in `invoke'
[INFO]       groovy/lang/MetaMethod.java:234:in `doMethodInvoke'
[INFO]       org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java:272:in `invokeMethod'
[INFO]       groovy/lang/MetaClassImpl.java:892:in `invokeMethod'
[INFO]       groovy/lang/Closure.java:279:in `call'
[INFO]       cuke4duke/internal/groovy/GroovyLanguage.java:33:in `invokeClosure'


I have used cucumber with Selenium before and it works really well using cuke4duke plugin. I am trying to write a tellurium test using Cucumber and it seems promising if I can instantiate any of the test base classes. I am afraid my lack of Groovy skills are not helping me.

Any help appreciated. 

Thanks
Haroon

Jian Fang

unread,
Feb 10, 2011, 1:14:01 PM2/10/11
to tellurium-...@googlegroups.com
Try

Given (~/The search is Hello World/){
    gsm = new GoogleSearchModule();
    gsm.defineUi();

   TelluriumGroovyTestCase.newInstance().with {
 connectSeleniumServer();
        connectUrl "http://www.google.com"
    }
}

Haroon Rasheed

unread,
Feb 10, 2011, 1:17:48 PM2/10/11
to tellurium-...@googlegroups.com
Tried that and still getting the NullPointer


[INFO]   Scenario: Hello World Scenario                   # features/GoogleSearch.feature:5
[INFO]     Given The search is Hello World                # test.GoogleSearchFeature$_run_closure1@21346812
[INFO]       org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NullPointerException: Cannot invoke method connectSeleniumServer() on null object (NativeException)
[INFO]       org/codehaus/groovy/reflection/CachedMethod.java:92:in `invoke'



Jian Fang

unread,
Feb 10, 2011, 1:25:00 PM2/10/11
to tellurium-...@googlegroups.com
Ok, it is a groovy test case. Please see trunk/core GoogleSearchGroovyTestCase.

You need to add
setUpForClass();
before connectSeleniumServer()

and add

tearDownForClass();

for your tearDown code.

Haroon Rasheed

unread,
Feb 10, 2011, 1:38:30 PM2/10/11
to tellurium-...@googlegroups.com
ahh.. yes it is a groovy test case, adding a call to setUpForClass works.


Thanks
Haroon

Jian Fang

unread,
Feb 10, 2011, 2:09:15 PM2/10/11
to tellurium-...@googlegroups.com
We may need to refactor the name later because it is ugly.
Reply all
Reply to author
Forward
0 new messages