Selenium中的java.lang.IllegalAccessError

时间:2013-05-08 08:20:21

标签: java exception selenium junit

我从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的基本单元测试,但它继续获取此Exeption:

  

java.lang.IllegalAccessError:尝试访问方法   org.openqa.selenium.browserlaunchers.LauncherUtils.getSeleniumResourceAsStream(Ljava /郎/字符串;)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)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 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)     在   org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)     在   org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)     在

     

org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

谢谢你:D

1 个答案:

答案 0 :(得分:0)

这可能是由于jar文件或运行时加载的类。你可以检查你的课程路径中是否有最新的Jar文件吗?尝试清理并再次构建项目。