- Uma
- Posts : 3
Join date : 2011-08-18
java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE
Mon Aug 29, 2011 3:54 am
1.I downloaded Jdk-7 and set the path in C:\Program Files\Java\jdk1.7.0\bin(Environment variable in Control panel)
2.I downloaded selenium server in C:\downloads(I am able to run the server using the following commands,
java –jar selenium-server-standalone-2.4.0.jar)
3.I downloaded Eclipse IDE and Created new project(myproject) and I created a package under this project com.example.tests.
while I create new project I added junit3.jar using Add library and I added Java client driver using Add External Jars
4.I recorded the script(I am opening google page and searching seleium) using selenium IDE and Exported Test case as-Junit3(RemoteControl) and I saved it.
(I am able to open this script and I copied the changed code from-C:\selenium\selrcexjav )
5.I created a new class(selrcexjav) under myprojec\com.example.tests
6.I past all the code here and i did modifications.This is my modified script
package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
import junit.framework.*; //added
public class selrcjav extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.google.com/", "*chrome");
}
public void testSelrcjav() throws Exception {
selenium.open("about:home");
selenium.type("id=searchText", "selenium");
selenium.click("id=searchSubmit");
selenium.waitForPageToLoad("30000");
selenium.click("link=Selenium - Web Browser Automation");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("Selenium"));
}
public static Test suite() {
//method added
return new TestSuite(selrcjav.class);
}
public void tearDown(){
//Added . Will be called when the test will complete
selenium.stop();
}
public static void main(String args[]) {
// Added. Execution will started from here.
junit.textui.TestRunner.run(suite());
7.I started the selnium server and I try to compile this as a java application in eclipse.
I am getting following error in eclipse
.E
Time: 0.156
There was 1 error:
1) testSelrcjav(com.example.tests.selrcjav)java.lang.NoClassDefFoundError: com/google/common/base/Charsets
at com.thoughtworks.selenium.HttpCommandProcessor.getOutputStreamWriter(HttpCommandProcessor.java:138)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:165)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:108)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:90)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:266)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:227)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:82)
at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:132)
at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:99)
at com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:80)
at com.example.tests.selrcjav.setUp(selrcjav.java:9)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:228)
at com.example.tests.selrcjav.main(selrcjav.java:40)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Charsets
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 23 more
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
could you please tell me where i am doing mistake?
It si little urgent,I need to give my demo,Please help me.
Thanks for your time
Thank you,
Uma
2.I downloaded selenium server in C:\downloads(I am able to run the server using the following commands,
java –jar selenium-server-standalone-2.4.0.jar)
3.I downloaded Eclipse IDE and Created new project(myproject) and I created a package under this project com.example.tests.
while I create new project I added junit3.jar using Add library and I added Java client driver using Add External Jars
4.I recorded the script(I am opening google page and searching seleium) using selenium IDE and Exported Test case as-Junit3(RemoteControl) and I saved it.
(I am able to open this script and I copied the changed code from-C:\selenium\selrcexjav )
5.I created a new class(selrcexjav) under myprojec\com.example.tests
6.I past all the code here and i did modifications.This is my modified script
package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
import junit.framework.*; //added
public class selrcjav extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.google.com/", "*chrome");
}
public void testSelrcjav() throws Exception {
selenium.open("about:home");
selenium.type("id=searchText", "selenium");
selenium.click("id=searchSubmit");
selenium.waitForPageToLoad("30000");
selenium.click("link=Selenium - Web Browser Automation");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("Selenium"));
}
public static Test suite() {
//method added
return new TestSuite(selrcjav.class);
}
public void tearDown(){
//Added . Will be called when the test will complete
selenium.stop();
}
public static void main(String args[]) {
// Added. Execution will started from here.
junit.textui.TestRunner.run(suite());
7.I started the selnium server and I try to compile this as a java application in eclipse.
I am getting following error in eclipse
.E
Time: 0.156
There was 1 error:
1) testSelrcjav(com.example.tests.selrcjav)java.lang.NoClassDefFoundError: com/google/common/base/Charsets
at com.thoughtworks.selenium.HttpCommandProcessor.getOutputStreamWriter(HttpCommandProcessor.java:138)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:165)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:108)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:90)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:266)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:227)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:82)
at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:132)
at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:99)
at com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:80)
at com.example.tests.selrcjav.setUp(selrcjav.java:9)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:228)
at com.example.tests.selrcjav.main(selrcjav.java:40)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Charsets
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 23 more
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
could you please tell me where i am doing mistake?
It si little urgent,I need to give my demo,Please help me.
Thanks for your time
Thank you,
Uma
- holleymcflyActive particpant
- Posts : 10
Join date : 2011-08-31
Re: java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE
Wed Aug 31, 2011 8:03 pm
Hi Uma,
I was confronted the same problem. After an hour work and a bit luck I finally could get one step forward:
I was a little bit confused, because the package com.google.common.base actually is part of the selenium server. So I gave it a try and added the server-jar file to the run configuration of the jUnit test - and it worked!
Hope I also managed to upload the screenshot correctly:
http ://i42.servimg.com/u/f42/16/82/28/51/runcon10.jpg
(pls remove the space in the URL. I am not allowed to post links as I registerd only to write this reply. New members may not post external links for 7 days....)
Good luck!
Greetings,
Holger
I was confronted the same problem. After an hour work and a bit luck I finally could get one step forward:
I was a little bit confused, because the package com.google.common.base actually is part of the selenium server. So I gave it a try and added the server-jar file to the run configuration of the jUnit test - and it worked!
Hope I also managed to upload the screenshot correctly:
http ://i42.servimg.com/u/f42/16/82/28/51/runcon10.jpg
(pls remove the space in the URL. I am not allowed to post links as I registerd only to write this reply. New members may not post external links for 7 days....)
Good luck!
Greetings,
Holger
- Uma
- Posts : 3
Join date : 2011-08-18
Re: java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE
Thu Sep 01, 2011 4:59 am
Hi Holger,
Thank you for the detailed soulation and the screenshot.
It is working for me.
Thank you
Uma
Thank you for the detailed soulation and the screenshot.
It is working for me.
Thank you
Uma
- holleymcflyActive particpant
- Posts : 10
Join date : 2011-08-31
Re: java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE
Thu Sep 01, 2011 4:16 pm
Great! Glad I could help.
Greets
Holger
Greets
Holger
- neeshpal
- Posts : 1
Join date : 2011-09-15
Re: java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE
Thu Sep 15, 2011 11:15 pm
Thanks for the solution.
I am not using Eclipse and running Junit test from command line and getting the exact error.
Does some one know how to add server-jar file to the run configuration of the jUnit test, when not using Eclipse.
I am not using Eclipse and running Junit test from command line and getting the exact error.
Does some one know how to add server-jar file to the run configuration of the jUnit test, when not using Eclipse.
- holleymcflyActive particpant
- Posts : 10
Join date : 2011-08-31
Re: java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE
Fri Sep 16, 2011 12:51 pm
Hi neeshal,
you have to put the jar-files to your classpath.
I find the explanation at the following site very usefull:
http://junit.sourceforge.net/doc/faq/faq.htm
Go to section 6.1 ("What CLASSPATH settings are needed to run JUnit?") and 6.2 ("Why do I get a NoClassDefFoundError when trying to test JUnit or run the samples?").
Greets,
Holger
you have to put the jar-files to your classpath.
I find the explanation at the following site very usefull:
http://junit.sourceforge.net/doc/faq/faq.htm
Go to section 6.1 ("What CLASSPATH settings are needed to run JUnit?") and 6.2 ("Why do I get a NoClassDefFoundError when trying to test JUnit or run the samples?").
Greets,
Holger
- hathupt
- Posts : 1
Join date : 2013-01-21
Re: java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE
Mon Jan 21, 2013 2:30 pm
holleymcfly wrote:Hi Uma,
I was confronted the same problem. After an hour work and a bit luck I finally could get one step forward:
I was a little bit confused, because the package com.google.common.base actually is part of the selenium server. So I gave it a try and added the server-jar file to the run configuration of the jUnit test - and it worked!
Hope I also managed to upload the screenshot correctly:
http ://i42.servimg.com/u/f42/16/82/28/51/runcon10.jpg
(pls remove the space in the URL. I am not allowed to post links as I registerd only to write this reply. New members may not post external links for 7 days....)
Good luck!
Greetings,
Holger
Thanks Holger for your solution. It works for me
- error in eclipse java.lang.RuntimeException: Could not start Selenium session: null
- Verify command when used with Java,JUNIT and Eclipse
- [Help] Problem of running selenium Testcase[Java Junit] with Selenium RC
- Is it necessary to use JUnit or TestNG with eclipse while using with Selenium RC?
- Selenium RC "java.lang.RuntimeException: Firefox couldn't be found in the path!" problem
Permissions in this forum:
You cannot reply to topics in this forum