How to export export a script from selenium IDE to a Java file and include it in Java project in eclipse

5,220 views
Skip to first unread message

anuja

unread,
Nov 15, 2011, 1:55:54 AM11/15/11
to Selenium Users
I am beginner user of seleium. i downloaded selenium RC server and
client zip files.
I created a new project in eclipse and added the jar file as project
reference.
how can i export selenium test from it IDE to eclipse java project?
Thanx in advance.

gouse basha

unread,
Nov 15, 2011, 2:01:13 AM11/15/11
to seleniu...@googlegroups.com
Hi,
Start recording using ide and cut & paste in ur java script.


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


Mallikarjun Yalagi

unread,
Nov 15, 2011, 2:04:15 AM11/15/11
to seleniu...@googlegroups.com
Hi anuja,

       To export selenium test from ide to eclipse java follow the steps:
1)open selenium ide
2)select the test cases
3)click on file option
4)select export test cases as
5)there you select junit4(remote control) if you are using junit or testng(Remote control) if you are using testng.
6)then save that file as .java
7)open that file and copy that code and paste it in eclipse.

On Tue, Nov 15, 2011 at 12:25 PM, anuja <anuja...@gmail.com> wrote:

Anuja Jain

unread,
Nov 15, 2011, 2:21:12 AM11/15/11
to seleniu...@googlegroups.com
i did exactly like your steps but when i am running the test as junit test it is throwing exceptions as below.
 
 
 
 

java.lang.NoClassDefFoundError: com/google/common/base/Function
 at Test1.setUp(Test1.java:17)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 ... 24 more

java.lang.NullPointerException
 at Test1.tearDown(Test1.java:29)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:37)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Mallikarjun Yalagi

unread,
Nov 15, 2011, 3:20:26 AM11/15/11
to seleniu...@googlegroups.com
go through this link: "http://seleniumready.blogspot.com/search/label/junit",compare the code.
Thanks&Regards
Mallappa Yalagi

anji prassana

unread,
Nov 15, 2011, 3:46:32 AM11/15/11
to seleniu...@googlegroups.com
Hi Anuja,
 This kind of exception will come if the required jar files are not available in your project.
 It seems to be you wrote the script using Web-driver but forgot to place the required jar
 files..

Go to the following URL and download the Java Client Driver form Selenium-Client Drivers section, Extract it and then copy all the jars presented in 'libs' folder along with 'selenium-java-2.11.0.jar' into your Project Build Path.Then it'll resolve...



On Tue, Nov 15, 2011 at 12:51 PM, Anuja Jain <anuja...@gmail.com> wrote:

anji prassana

unread,
Nov 15, 2011, 4:02:17 AM11/15/11
to seleniu...@googlegroups.com
I forget to copy the link..
http://seleniumhq.org/download/
 from this link download selenium 2.0+ version client driver.

tulsi.tester

unread,
Nov 15, 2011, 5:29:57 AM11/15/11
to Selenium Users
Hi Anuja,

I think the following exception caused due to the Class name. The
class name should be same as the File name that you have saved.
Suppose if you are saving the file as "NewTest.java", then the class
name of the file should be NewTest. Try this and let me know.
> On Tue, Nov 15, 2011 at 12:34 PM, Mallikarjun Yalagi <yalagi.ma...@gmail.com
>
> > wrote:
> > Hi anuja,
>
> >        To export selenium test from ide to eclipse java follow the steps:
> > 1)open selenium ide
> > 2)select the test cases
> > 3)click on file option
> > 4)select export test cases as
> > 5)there you select junit4(remote control) if you are using junit or
> > testng(Remote control) if you are using testng.
> > 6)then save that file as .java
> > 7)open that file and copy that code and paste it in eclipse.
>

Anuja Jain

unread,
Nov 16, 2011, 12:16:02 AM11/16/11
to seleniu...@googlegroups.com
 my test is running in eclipse now. thanx for ur help..
but the in the code SeleneseTestCase .
this is shown.I am not getting why it is shown like this.
 

 

import com.thoughtworks.selenium.*;

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import java.util.regex.Pattern;

public class FirstTest extends SeleneseTestCase {

@Before

public void setUp() throws Exception {

selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://inlvt46.iind.intel.com/");

selenium.start();

}

@Test

public void testTest1() throws Exception {

selenium.open("/NBConsole/");

assertTrue(

selenium.isTextPresent("Select View"));

}

@After

public void tearDown() throws Exception {

selenium.stop();

}

}

Sasi kumar

unread,
Nov 16, 2011, 12:27:19 AM11/16/11
to Selenium Users
I didnt get you what is the error shown in eclipse?

On Nov 16, 10:16 am, Anuja Jain <anujamj...@gmail.com> wrote:
>  my test is running in eclipse now. thanx for ur help..
> but the in the code *SeleneseTestCase .*
> this is shown.I am not getting why it is shown like this.
>
> *
>
> *
>
> import com.thoughtworks.selenium.*;
>
> import org.junit.After;
>
> import org.junit.Before;
>
> import org.junit.Test;
>
> *import java.util.regex.Pattern*;
>
> *public class* FirstTest *extends* *SeleneseTestCase* {
>
> @Before
>
> *public* *void* setUp() *throws* Exception {
>
> *selenium* = *new* DefaultSelenium("localhost", 4444, "*chrome", "http://inlvt46.iind.intel.com/");
>
> *selenium*.start();
>
> }
>
>  @Test
>
> *public* *void* testTest1() *throws* Exception {
>
> *selenium*.open("/NBConsole/");
>
> *assertTrue*(
>
> *selenium*.isTextPresent("Select View"));
>
> }
>
>  @After
>
> *public* *void* tearDown() *throws* Exception {
>
> *selenium*.stop();
>
>
>
>
>
>
>
> }
> }

Krishnan Mahadevan

unread,
Nov 16, 2011, 12:47:09 AM11/16/11
to seleniu...@googlegroups.com
You mean to say that you are getting a deprecation message in eclipse ??
A strike through on a class or method normally means that, that particular class/method is deprecated (marked for deletion and would be deleted in the next release or the one after that).. its an indication to you that you are not to be using that method/class anymore but instead use something else.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


>
>
>
>
>
>
>
> }
> }

Anuja Jain

unread,
Nov 16, 2011, 12:53:46 AM11/16/11
to seleniu...@googlegroups.com
Yes exactly i am getting deprecattion message.so i will use SeleneseTestBase instead of SeleneseTestCase.
 
Thanks,
Anuja

Mark Collin

unread,
Nov 16, 2011, 1:27:32 AM11/16/11
to seleniu...@googlegroups.com

That’s because it’s deprecated.  You want to extend SeleneseTestBase instead.

--

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


-- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify postm...@ardescosolutions.com
Reply all
Reply to author
Forward
0 new messages