このコードは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());
}
}
これは Selenium RC を使用した基本的な単体テストですが、次の例外が引き続き発生します。
java.lang.IllegalAccessError: メソッド org.openqa.selenium.browserlaunchers.LauncherUtils.getSeleniumResourceAsStream(Ljava/lang/String;)Ljava/io/InputStream; にアクセスしようとしました。クラス org.openqa.selenium.server.SeleniumServer の org.openqa.selenium.server.SeleniumServer.logVersionNumber(SeleniumServer.java:265) の org.openqa.selenium.server.SeleniumServer.logStartupInfo(SeleniumServer.java:673) からorg.openqa.selenium.server.SeleniumServer.(SeleniumServer.java:229) で org.openqa.selenium.server.SeleniumServer.(SeleniumServer.java:205) で Practice.TestMangaPanda.setUp(TestMangaPanda.java:21) で junit .framework.TestCase.runBare(TestCase.java:132) at junit.framework.TestResult$1.protect(TestResult.java:110) junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult .
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)
ありがとう:D