I got this code from BitMotif - Selenium Remote Control For Java — A Tutorial
package Practice;
import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.DefaultSelenium;
import junit.framework.TestCase;
import org.openqa.selenium.server.SeleniumServer;
public class TestMangaPanda
extends TestCase
{
private static final String MAX_WAIT_TIME_IN_MS = "6000";
private static final String BASE_URL = "http://www.bitmotif.com";
private Selenium selenium = new DefaultSelenium( "localhost",
4444,
"*firefox",
BASE_URL);
SeleniumServer seleniumServer;
public void setUp() throws Exception
{
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}
public void tearDown()
throws Exception
{
selenium.stop();
seleniumServer.stop();
}
public void testClickingLink()
throws Exception
{
selenium.open(BASE_URL);
selenium.click("link=Test Page For Selenium Remote Control");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
String expectedTitle = "Bit Motif » Test Page For Selenium Remote Control";
assertEquals(expectedTitle, selenium.getTitle());
}
}
It is a basic Unit Testing using Selenium RC, but it keep on get this Exeption:
java.lang.IllegalAccessError: tried to access method org.openqa.selenium.browserlaunchers.LauncherUtils.getSeleniumResourceAsStream(Ljava/lang/String;)Ljava/io/InputStream; from class org.openqa.selenium.server.SeleniumServer at org.openqa.selenium.server.SeleniumServer.logVersionNumber(SeleniumServer.java:265) at org.openqa.selenium.server.SeleniumServer.logStartupInfo(SeleniumServer.java:673) at org.openqa.selenium.server.SeleniumServer.(SeleniumServer.java:229) at org.openqa.selenium.server.SeleniumServer.(SeleniumServer.java:205) at Practice.TestMangaPanda.setUp(TestMangaPanda.java:21) at junit.framework.TestCase.runBare(TestCase.java:132) 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)
Thank You :D
This could be due to the jar files or the classes loaded at runtime. Can you please check whether you have latest Jar files in your class path? Try clean-up and build the project again.