2013-05-08 41 views
1

我得到這個代碼BitMotif - Selenium Remote Control For Java — A Tutorialjava.lang.IllegalAccessError硒

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: 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)

謝謝:D

回答

0

這可能是由於jar文件或運行時加載的類造成的。你能否檢查你的班級路徑中是否有最新的Jar文件?嘗試清理並重新構建項目。

相關問題