[英]java.lang.IllegalAccessError in Selenium
我从BitMotif获得此代码-Java的硒遥控器—教程
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 / lang / String;)Ljava / io / InputStream; 来自org.openqa.selenium.server.SeleniumServer.logStartupInfo(SeleniumServer.java:673)上的org.openqa.selenium.server.SeleniumServer.logVersionNumber(SeleniumServer.java:265)上的org.openqa.selenium.server.SeleniumServer类org.openqa.selenium.server.SeleniumServer。(SeleniumServer.java:229)位于org.openqa.selenium.server.SeleniumServer。(SeleniumServer.java:205)位于Practice.TestMangaPanda.setUp(TestMangaPanda.java:21) .framework.TestCase.runBare(TestCase.java:132)位于junit.framework.TestResult $ 1.protect(TestResult.java:110)位于junit.framework.TestResult.runProtected(TestResult.java:128)位于junit.framework.TestResult .run(TestResult.java:113)位于junit.framework.TestCase.run(TestCase.java:124)位于junit.framework.TestSuite.runTest(TestSuite.java:243)位于junit.framework.TestSuite.run(TestSuite。 java:238)在org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)处在org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)处 位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)的rg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
org.eclipse上的org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)上的org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)。 jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
谢谢你:D
这可能是由于jar文件或运行时加载的类所致。 您能否检查您的类路径中是否有最新的Jar文件? 尝试清理并再次构建项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.