Not able to make the Selenium Test in java run.

0 views
Skip to first unread message

Khasim Khan

unread,
Aug 21, 2009, 2:50:31 PM8/21/09
to selenium-users...@googlegroups.com
Am new to Selenium and a java handicap. I read through and tried to perform my first selenium test in Java using JUnit framework. No success yet. Please can you help with steps in detail assuming I don't how to set the classpath even (not really).

Thanks in advance.

Below is my code.

//package com.example.tests;
import com.thoughtworks.selenium.*;\\ import junit.framework.*;\\ import java.util.regex.Pattern;
public class GoogleTest extends SeleneseTestCase {\\ public void setUp() throws Exception {\\   setUp("[http://www.google.com/]", "*chrome");\\ }\\ public void GoogleTestSRC() throws Exception {\\   selenium.open("/");\\   assertEquals("Google", selenium.getTitle());\\   selenium.type("q", "Selenium RC help");\\   selenium.click("btnI");\\   selenium.waitForPageToLoad("30000");\\   assertEquals("Google", selenium.getTitle());\\ }\\ public static Test suite() {\\   return new TestSuite(GoogleTest.class);\\ }\\ public void tearDown(){\\   selenium.stop();\\ }\\ public static void main(String args[]) {\\   junit.textui.TestRunner.run(suite());\\ }\\ }
Which gives me the following result:

C:\selenium-RC\selenium-java>javac GoogleTest.java
C:\selenium-RC\selenium-java>java GoogleTest\\ Exception in thread "main" java.lang.NoClassDefFoundError: GoogleTest\\ Caused by: java.lang.ClassNotFoundException: GoogleTest\\         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)\\ Could not find the main class: GoogleTest.  Program will exit.
C:\selenium-RC\selenium-java>

Request your help to know the do's and don't of selenium.

Regards,
Khasim.

Khasim Khan

unread,
Aug 24, 2009, 10:39:27 PM8/24/09
to selenium-users...@googlegroups.com
Thank you Tarun.

I succeeded to run my script.

Now struck with using google chrome, Selenium provides help for the
error and however following the steps doesn't fix the issue.

If you have run tests in google chrome please provide steps to help me.

Thanks


Tarun

unread,
Aug 24, 2009, 11:43:45 PM8/24/09
to selenium-users...@googlegroups.com
Well I have never worked on chrome... would try to help you if you could point out errors specifically.

~ T

Reply all
Reply to author
Forward
0 new messages