Friday, October 28, 2011

No Class Definition Found Error in Eclipse

If we want to run Selenium Java code from Eclipse, we need to include the following jar files in our class path.

1) selenium-java-2.x.jar (Java Client Driver)
2) JUnit-4.x.jar or TestNG.jar (Testing Framework)

These two files are enough for executing our Selenium Automation scripts. Sometimes we might get the below error while executing the script. In this scenario, we need to include our selenium server jar file in the class path which will fix this issue. I have experienced this issue several times and this solution has fixed my problem. Please try this.

selenium-standalone-server-2.x.jar


Expected Error:

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.eviltester.seleniumtutorials.PlacedOrder_final.setUp(PlacedOrder_final.java:12)
at junit.framework.TestCase.runBare(TestCase.java:132)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:228)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
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.Charsets
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 23 more

Wednesday, October 19, 2011

Format Option missing in Selenium IDE menubar

Some people are only using Selenium IDE to prepare their test suites and run it from there. But, most of the people using Selenium RC code and run it from their favourite language editor. Usually they record the web application actions in IDE and convert the selenese table format into Java or C# or Perl or Ruby etc format. Those format can be copy & pasted into language editors like Eclipse (Java) or Visual Studio (C#) and we can run the code from there.

But, the recent issue with IDE is that we dont find any language options under Format. These options are disabled from the version IDE 1.0.11 as they declared these options as Experimental features. Because, if you convert them into any language format and make some modifications, again IDE will not be able to convert them into selenese table format if you want to revert back. If you still want those experimental features, follow the below steps in IDE:

1) Under Options menu, click on Options
2) Select "Enable experimental features" option and click on OK.



Now come back to Options --> Format. You will be able to see all the language formats.

About this Blog

I got interested in Selenium Automation Tool and done automation for different projects. When I started this tool, I didn't get proper support or forum to give some advise for the errors which I faced. However, I have done research most of the time and found solutions for some familiar Selenium issues. I felt that I want to share the solutions with selenium starters or users who are facing similar issues and started this blog.

Hope this blog will be helpful for Selenium users.

Thanks
VEERA