我一直在尝试在itelliJ中运行selenium基本测试,我收到以下错误

时间:2017-06-21 19:18:54

标签: java maven selenium intellij-idea

  

Java.lang.IllegalAccessError:尝试访问类   来自类的org.openqa.selenium.os.ExecutableFinder   org.openqa.selenium.firefox.FirefoxBinary

     

在   org.openqa.selenium.firefox.FirefoxBinary.locateFirefoxBinariesFromPlatform(FirefoxBinary.java:433)     在   org.openqa.selenium.firefox.FirefoxBinary。(FirefoxBinary.java:108)     在   org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:122)     在   com.masteringselenium.BasicTest.googleExampleThatSearchesFor(BasicTest.java:21)     在   com.masteringselenium.BasicTest.googleCheeseExample(BasicTest.java:43)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)     在org.testng.internal.Invoker.invokeMethod(Invoker.java:714)at   org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)at at   org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)at at   org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)     在   org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)     在org.testng.TestRunner.privateRun(TestRunner.java:767)at   org.testng.TestRunner.run(TestRunner.java:617)at   org.testng.SuiteRunner.runTest(SuiteRunner.java:334)at   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)at at   org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)at at   org.testng.SuiteRunner.run(SuiteRunner.java:240)at   org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)at   org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)at   org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)at at   org.testng.TestNG.runSuitesLocally(TestNG.java:1123)at at   org.testng.TestNG.run(TestNG.java:1031)at   org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)at at   org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)at at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

1 个答案:

答案 0 :(得分:0)

根据您运行的Selenium的版本,您可能需要在实例化Firefox驱动程序时指定Firefox二进制文件的路径。例如,使用Selenium 2.53.1看起来像这样:

FirefoxBinary ffBinary = new FirefoxBinary(new File("path to your firefox.exe"));
FirefoxProfile ffProfile = new FirefoxProfile();
driver = new FirefoxDriver(ffBinary,ffProfile);