SeliniumConnector is Null

2 views
Skip to first unread message

KevinO

unread,
May 26, 2011, 1:06:10 PM5/26/11
to tellurium-users
I have the following code:

public class TestingTestCase extends TelluriumJUnitTestCase {

//private static Logger logger =
Logger.getLogger(TestingTestCase.class.getName());
private static LogonModule Logon;
@BeforeClass
public static void initUi() {
Logon = new LogonModule();
}
@Test
public void testEnvironment(){
setCustomConfig(true, 5555, "*firefox", true, "");
connectUrl("http://localhost/");
assertEquals("output","output");
}
}

I'm getting a Cannont invoke method open() on null object. It is
referencing to the method
org.telluriumsource.component.connector.SeleniumConnector.connectUrl()

I noticed in the class that connectSeleniumServer() has the
instantiation of the sel object comment out. This would lead to the
issues of that object being null. Have I missed something in setup?

The following is my stack trace: http://paste.scsys.co.uk/107533

Jian Fang

unread,
May 26, 2011, 4:02:23 PM5/26/11
to telluri...@googlegroups.com
Ok, I will try out your code. Which version of Tellurium are you using?

Thanks,

Jian


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


KevinO

unread,
May 26, 2011, 4:16:06 PM5/26/11
to tellurium-users
0.8.0-RC1

On May 26, 3:02 pm, Jian Fang <john.jian.f...@gmail.com> wrote:
> Ok, I will try out your code. Which version of Tellurium are you using?
>
> Thanks,
>
> Jian
>

Jian Fang

unread,
May 26, 2011, 6:01:01 PM5/26/11
to telluri...@googlegroups.com
You should call connectSeleniumServer() before you call connectUrl().

The comment out is fine because the Tellurium Injector framework will automatically inject the instance to the
Selenium connector.

Try this,


    @BeforeClass
    public static void initUi() {
        Logon = new LogonModule();
        connectSeleniumServer();

    }

    @Test
    public void testEnvironment() {
        setCustomConfig(true, 5555, "*firefox", true, "");
        connectUrl("http://localhost/");
        assertEquals("output", "output");
    }

Thanks,

Jian

Jian Fang

unread,
May 26, 2011, 6:11:19 PM5/26/11
to telluri...@googlegroups.com
BTW, Tellurium 0.8.0 provides a new way to change the configuration at runtime, i.e, the following two methods

String getEnvironment(String key)
void setEnvironment(String key, String value)

For example, here is the test case in the LogonTestCase on trunk/core project.

    @Test
    public void testEnvironment(){
        String fileName = (String) getEnvironment("tellurium.test.result.filename");
        assertNotNull(fileName);
        System.out.println("Default test result file name " + fileName);

        setEnvironment("tellurium.test.result.filename", "/tmp/TestResult.output");
        fileName = (String) getEnvironment("tellurium.test.result.filename");
        assertEquals("/tmp/TestResult.output", fileName);
        System.out.println("New file name " + fileName);

KevinO

unread,
May 26, 2011, 7:36:08 PM5/26/11
to tellurium-users
That got me a little further.

org.telluriumsource.exception.TelluriumException: Cannot start
selenium: Could not start Selenium session:
I believe that Selenium is error out here:
org.telluriumsource.component.connector.CustomSelenium.startSeleniumSession(CustomSelenium.groovy:
66)

I'm trying to get the source code to compile in eclipse so that I can
debug this but am getting "The annotation @Provider must define the
attribute type" error.

I tried this in 0.8.0-RC1 and then updated to 0.8.0-RC2 and got the
same error.

Thanks for the help.


On May 26, 5:01 pm, Jian Fang <john.jian.f...@gmail.com> wrote:
> You should call connectSeleniumServer() before you call connectUrl().
>
> The comment out is fine because the Tellurium Injector framework will
> automatically inject the instance to the
> Selenium connector.
>
> Try this,
>
>     @BeforeClass
>     public static void initUi() {
>         Logon = new LogonModule();
>         connectSeleniumServer();
>     }
>
>     @Test
>     public void testEnvironment() {
>         setCustomConfig(true, 5555, "*firefox", true, "");
>         connectUrl("http://localhost/");
>         assertEquals("output", "output");
>     }
>
> Thanks,
>
> Jian
>

Jian Fang

unread,
May 26, 2011, 8:33:05 PM5/26/11
to telluri...@googlegroups.com
I cannot figure out the problem until see more detailed stack trace.

If you like to debug the code, I would suggestion you check out the
whole tellurium project trunk, load up the project to IntelliJ IDEA (community version is fine), and then create your test case in the core project. After that, you can debug every line of the code of Tellurium. There are also many test cases in the core project, which can be used as examples for you.

The @Provider is provided by the tellurium injector module, do you have that jar file in your class path?

Thanks,

Jian

KevinO

unread,
May 27, 2011, 12:01:46 AM5/27/11
to tellurium-users
I've already downloaded IntelliJ, community version and the trunk line
of the source code. I was just hoping that I could get it to compile
in eclipse. I'll try tomorrow to get it working in IntelliJ and see
if I can narrow down the problem.

Thanks,

KevinO

On May 26, 7:33 pm, Jian Fang <john.jian.f...@gmail.com> wrote:
> I cannot figure out the problem until see more detailed stack trace.
>
> If you like to debug the code, I would suggestion you check out the
> whole tellurium project trunk, load up the project to IntelliJ IDEA
> (community version is fine), and then create your test case in the core
> project. After that, you can debug every line of the code of Tellurium.
> There are also many test cases in the core project, which can be used as
> examples for you.
>
> The @Provider is provided by the tellurium injector module, do you have that
> jar file in your class path?
>
> Thanks,
>
> Jian
>

Hari

unread,
May 31, 2011, 2:38:45 AM5/31/11
to telluri...@googlegroups.com
Hi,
   HI am executing 100 and more test cases in my project.Each and every testcase am using the following code.
 
@Before

public void setUpForTest() {

connectUrl(http://localhost:8080/web.jsp);

}

If i want to change the url  mean. i have to manually change the url in my all testcases.....

How to  parameterized  url code or can you help me ..

 

 

 

 

Jian Fang

unread,
May 31, 2011, 10:18:03 AM5/31/11
to telluri...@googlegroups.com
Both JUnit 4 and TestNG provide parameterized tests, but I am not sure if they support the parameterized @Before or @BeforeMethod methods.

In Tellurium 0.8.0, you read the urls from somewhere by using


void setEnvironment(String key, String value)

to store it to the environment, then you could call

String getEnvironment(String key)

to fetch it from the environment in your test case.
But not sure if this is what you want.

--

Hari

unread,
Jun 1, 2011, 7:34:57 AM6/1/11
to telluri...@googlegroups.com
Hi,
   Am using Japanese language and running the testcases individually. Its working fine....
 
 Am executing the build.xml  Japanese character not accepting. The following is Error message thrown..
 
[javac] C:\workspace\test\src\com\login.java:35: Œx :‚±‚Ì•¶Žš‚Í AƒGƒ“ƒR [ƒfƒBƒ“ƒO UTF8 ‚Ƀ}ƒbƒv‚Å‚«‚Ü‚¹‚ñ B

[javac] assertTrue(str.contains("���[�U���܂��̓p�X���[�h���͂��Ă��������B"));

 ERROR: Element uimcal={"rid":"Mydata.Nobr","locator":"jquery=table.mydata nobr:te_text(???s)"} not found
 
Test com.login FAILED
 
 
 ??? Are Japanese character. Can you help me. How to resolve it..
 
Regards,
Hari
 
 
 

Jian Fang

unread,
Jun 1, 2011, 10:45:29 AM6/1/11
to telluri...@googlegroups.com
Should be related to utf-8 encode. Will take a look tonight.

 
 
 

--

Jian Fang

unread,
Jun 1, 2011, 6:15:55 PM6/1/11
to telluri...@googlegroups.com
I used Tellurium IDE to record a test from a Japanese web site and  here are the UI module

class JapaneseRedCrossModule extends DslContext {
    public void defineUi() {
        ui.Container(uid: "A", clocator: [tag: "a", title: "とっさの手当・予防を学びたい"]) {
            Image(uid: "Rollover", clocator: [tag:
            "img", direct: "true", class: "rollover"])
        }
    }

    void clickLink() {
        click "A.Rollover"
        waitForPageToLoad 30000
    }

}

and test case:


public class JapaneseRedCrossTestCase extends TelluriumJUnitTestCase {
    private static JapaneseRedCrossModule jrm;


    @BeforeClass
    public static void initUi() {
        jrm = new JapaneseRedCrossModule();
        jrm.defineUi();
        connectSeleniumServer();
    }

    @Before
    public void connect() {
        connectUrl("http://www.jrc.or.jp/index.html");
    }

    @Test
    public void testClickLink() {
        jrm.clickLink();
    }
}

Looks like tellurium core does not have any problem to handle the Japanese characters. See the log here:

or alternatively the selenium server is running in proxy injection mode)
18:11:36.144 INFO - Got result: OK on session 6c07cb867f074a3bb290f2f86e41f9e6
18:11:36.341 INFO - Command request: getBundleResponse[[{"uid":"A.Rollover","args":["jquery=a[title=とっさの手当・予防を学びたい] > img.rollover"],"name":"click","sequ":2}], ] on session 6c07cb867f074a3bb290f2f86e41f9e6
18:11:36.439 INFO - Got result: OK,[] on session 6c07cb867f074a3bb290f2f86e41f9e6
18:11:36.459 INFO - Command request: waitForPageToLoad[30000, ] on session 6c07cb867f074a3bb290f2f86e41f9e6
18:11:38.618 INFO - Got result: OK on session 6c07cb867f074a3bb290f2f86e41f9e6
18:11:38.627 INFO - Command request: testComplete[, ] on session 6c07cb867f074a3bb290f2f86e41f9e6

Could you create a test case to reproduce your problem using the web site http://www.jrc.or.jp/index.html and send it to us?

Or did you use utf-8 String when you type in input characters?

Hari

unread,
Jun 3, 2011, 2:43:51 AM6/3/11
to telluri...@googlegroups.com
Hi,

   The test case are sucessfully executed. result:pass.... But while executing the testcases in build.xml. The Characters are not accepting

Buildfile: C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\build.xml

clean:

[echo] Cleaning ...

[delete] Deleting directory C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\out\production

[delete] Deleting directory C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\out\test

init:

[echo] Initializing project...

[mkdir] Created dir: C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\out\production

[mkdir] Created dir: C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\out\test

compile-tellurium:

[echo] Compiling java...

[groovyc] Compiling 2 source files to C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\out\production

[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

[groovyc] C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\src\com\ibi\idp\test\Manage_data_profiler_Groovy.groovy: 41: unexpected char: '\' @ line 41, column 136.

[groovyc] ݍ܂ׂẴf[^vt@C\܂B

[groovyc] ^

[groovyc]

[groovyc] 1 error


BUILD FAILED

C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\build.xml:118: Compilation Failed


Total time: 3 seconds



ANT BUILD.XML


<?xml version="1.0"?>

<project name="tellurium-testng" default="compile-test" basedir=".">

<property name ="basedir" value ="C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES" />

<property name="dir.project" value="${basedir}" />


<property file="build.properties" />


<property name="dir.source" value="${dir.project}/src" />

<property name="dir.source.tellurium" value="${dir.source}/com/ibi/idp/test" />

<property name="dir.source.test" value="${dir.source}/com/ibi/idp/test" />


<property name="dir.build" value="${dir.project}/out" />

<property name="dir.build.tellurium" value="${dir.build}/production" />

<property name="dir.build.test" value="${dir.build}/test" />

<property name="dir.lib" value="${dir.project}/lib" />


<path id="lib.path">

<fileset dir="${dir.lib}">

<include name="*.jar" />

<exclude name="*-src.jar" />

<include name="*.class" />

</fileset>

</path>



<!-- Match runtime libraries -->

<patternset id="pattern.libs">

<include name="**/*.jar" />

<exclude name="**/*-src.jar"/>

<!--exclude name="**/*junit.jar"/-->

</patternset>


<path id="junit.classpath">

<fileset dir="${dir.lib}">

<include name="junit*.jar"/>

</fileset>

</path>


<path id="tellurium.classpath">

<path refid="lib.path" />

<pathelement location="${dir.build.tellurium}" />

</path>


<path id="test.classpath">

<path refid="tellurium.classpath" />

<path refid="junit.classpath" />

<pathelement location="${dir.build.test}" />

</path>


<path id="project.classpath">

<path refid="test.classpath" />

</path>


<taskdef name="junit"

classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"

classpathref="junit.classpath" />


<target name="clean">

<echo message="Cleaning ..." />

<delete dir="${dir.build.tellurium}" />

<delete dir="${dir.build.test}" />

</target>


<target name="init">

<echo message="Initializing project..." />

<tstamp>

<format property="time.formatted"

pattern="MM/dd/yyyy hh:mm:ss a" unit="hour" />

</tstamp>

<mkdir dir="${dir.build}" />

<mkdir dir="${dir.build.tellurium}" />

<mkdir dir="${dir.build.test}" />

</target>


<macrodef name="compile-java">

<!-- required attributes -->

<attribute name="srcdir" />

<attribute name="destdir" />

<attribute name="excludes" default="" />


<!-- these defaults can be changed using properties -->

<attribute name="compiler" default="${javac.compiler}" />

<attribute name="debug" default="${javac.debug}" />

<attribute name="optimize" default="${javac.optimize}" />

<attribute name="deprecation" default="${javac.deprecation}" />

<attribute name="fork" default="${javac.fork}" />


<!-- these defaults can only be overridden explicitly by a task -->

<attribute name="encoding" default="UTF-8" />

<attribute name="includeAndRunTime" default="no" />

<attribute name="failonerror" default="false" />


<!-- this element sucks up all elements when the macro is used -->

<element name="javac-elements" implicit="yes" />


<!-- the macro body -->

<sequential>

<javac srcdir="@{srcdir}"

excludes="@{excludes}"

destdir="@{destdir}" compiler="@{compiler}"

debug="@{debug}"

optimize="@{optimize}"

deprecation="@{deprecation}"

fork="@{fork}"

encoding="@{encoding}" failonerror="@{failonerror}">

</javac>

</sequential>

</macrodef>


<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"

classpathref="lib.path"/>


<target name="compile-tellurium" depends="init">

<echo message="Compiling java..." />

<groovyc srcdir="${dir.source.tellurium}"

destdir="${dir.build.tellurium}">

<classpath refid="lib.path" />

<!--javac source="1.5" target="1.5" debug="on" /-->

</groovyc>

<javac srcdir="${dir.source.tellurium}"

destdir="${dir.build.tellurium}">

<classpath refid="tellurium.classpath" />

</javac>

</target>


<target name="compile-test" depends="clean, compile-tellurium">

<echo message="Compiling test.." />

<groovyc srcdir="${dir.source.test}" destdir="${dir.build.test}">

<classpath refid="tellurium.classpath" />

<include name="**" />

</groovyc>

<javac srcdir="${dir.source.test}"

destdir="${dir.build.test}">

<classpath refid="test.classpath" />

</javac>

</target>

<target name="run-single-test" depends="compile-test">

<junit printsummary="yes" errorProperty="test.failed"

failureProperty="test.failed">

<classpath refid="project.classpath" />

<test name="com.ibi.idp.test.User_Group_Role_010" haltonfailure="yes" outfile="result">

<formatter type="xml" />

</test>

</junit>

<junitreport todir=".">

<fileset dir=".">

<include name="result.xml" />

</fileset>

<report format="frames" todir="./report/" />

</junitreport>


</target>

<target name="run-unit-tests" depends="compile-test">

<junit fork="yes" forkmode="once" maxmemory="1024m"

printsummary="yes"

failureProperty="test.failed">

<classpath refid="project.classpath" />

<classpath refid="test.classpath" />

<formatter type="brief" usefile="false" />

<formatter type="xml" />

<batchtest todir="${dir.build.test}">

<fileset dir="${dir.source}">

<include name="**/"/>

</fileset>

</batchtest>

</junit>

<!--

<fail if="test.failed" >

</fail>-->

<junitreport todir=".">

<fileset dir="C:\Documents and Settings\Axtst022\workspace\AUTOMATION_JAPANIES\out\test">

<include name="TEST-*.xml" />

</fileset>

<report format="frames" todir="./report/html" />

</junitreport>

</target>


</project>



Jian Fang

unread,
Jun 3, 2011, 10:23:06 AM6/3/11
to telluri...@googlegroups.com
Try to add  encoding:"UTF-8" for the groovyc task to see if it helps, see more details here:

http://groovy.codehaus.org/The+groovyc+Ant+Task

Hari

unread,
Jun 8, 2011, 1:52:01 AM6/8/11
to telluri...@googlegroups.com
Hi ,
 
    In groovyc the encoding code mentioned as US-ASCII. If we change it as UTF -8. Is it work fine ?
 
 
 String encoding = null;
    try {
      encoding = System.getProperty("file.encoding", "US-ASCII");
    }
    catch (Exception e) {
    }
    try {
      encoding = System.getProperty("groovy.source.encoding", encoding);
    }
 
Regards,
Hari

Hari

unread,
Jun 8, 2011, 8:25:30 AM6/8/11
to telluri...@googlegroups.com

HI ,
I tried to execute With UTF-8. It also not working. Can you help me in any way

Jian Fang

unread,
Jun 8, 2011, 6:17:47 PM6/8/11
to telluri...@googlegroups.com
You could post your question to Groovy mailing list to see if someone could help you there.

http://groovy.codehaus.org/Mailing+Lists

--

Hari

unread,
Jun 9, 2011, 2:02:51 AM6/9/11
to telluri...@googlegroups.com
Thank you
Reply all
Reply to author
Forward
0 new messages