The type org.openqa.selenium.firefox.FirefoxDriver is not accessible

烂漫一生 提交于 2020-01-09 12:07:05

问题


I need help in setting up selenium in MAC OS. I have added all the required selenium jar files and java JRE to build path. I have added java path in .profile But still I am still getting error for Firefox driver.

The type org.openqa.selenium.firefox.FirefoxDriver is not accessible

Can you please help.


回答1:


To resolve this issue,

  1. create a new Java project with JRE syetm libraray (JavaSE 1.8)
  2. copy jar file and build path
  3. copy driver executables

Create new class and move on with your work!!!




回答2:


This error message...

The type org.openqa.selenium.firefox.FirefoxDriver is not accessible

...implies that the GeckoDriver was not accessible by your program/script,

Your main issue is the presence of numerous unwanted JAR files containing the same class which are:

  • selenium-server-standalone-3.14.0.jar
  • Selenium-Java client JARs.
  • selenium-firefox-driver-2.35.0.jar

Solution

  • Remove all the JARs and add back only selenium-server-standalone-3.14.0.jar
  • Download the required format of GeckoDriver executable from mozilla/geckodriver, extract the binary and then initialize the FirefoxDriveras follows:

    //imports
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    
    //other lines of code
    System.setProperty("webdriver.gecko.driver","C:\\path\\to\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.get("https://www.google.com/");
    



回答3:


From what I can see in your 'Referenced Libraries' folder, you seem to have added both the selenium-standalone-3.x.x.jar and the individual client-combined-3.x.x versions of the jar files (selenium client jars for java). Is it possible that your eclipse does not know which libraries to finally use? Request you to remove all the libraries in your build path and add ONLY the selenium-server-standalone-3.x.x.jar file. Once done, refresh and this should resolve.

Also, once the right jars are in place, the import should resolve even without the System.setProperty instruction in your class file.

If the issue persists, could you please paste a screen capture without the right-click context menu on the error? Hope this helps.



来源:https://stackoverflow.com/questions/53126346/the-type-org-openqa-selenium-firefox-firefoxdriver-is-not-accessible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!