Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
Uma
Posts : 3
Join date : 2011-08-18

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty 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
avatar
holleymcfly
Active particpant
Active particpant
Posts : 10
Join date : 2011-08-31

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty 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
avatar
Uma
Posts : 3
Join date : 2011-08-18

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty 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
avatar
holleymcfly
Active particpant
Active particpant
Posts : 10
Join date : 2011-08-31

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty 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
avatar
neeshpal
Posts : 1
Join date : 2011-09-15

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty 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.
avatar
holleymcfly
Active particpant
Active particpant
Posts : 10
Join date : 2011-08-31

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty 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
avatar
hathupt
Posts : 1
Join date : 2013-01-21

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty 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 Smile
Sponsored content

java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE Empty Re: java.lang.NoClassDefFoundError-Selenium RC with Junit and EClipse IDE

Back to top
Permissions in this forum:
You cannot reply to topics in this forum