Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
933 views
in Technique[技术] by (71.8m points)

selenium - Getting IllegalAccessError warning

I'm trying to write my first program in selenium-java but in a short program of few lines I'm getting following error:

Exception in thread "main" java.lang.IllegalAccessError: tried to access class org.openqa.selenium.os.ExecutableFinder from class org.openqa.selenium.firefox.FirefoxBinary at org.openqa.selenium.firefox.FirefoxBinary.locateFirefoxBinariesFromPlatform(FirefoxBinary.java:418) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:108) at java.util.Optional.orElseGet(Unknown Source) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:204) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:108) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:104) at com.packt.selenium.chapter1.NavigateToAUrl.main(NavigateToAUrl.java:12)

My code is:

package com.packt.selenium.chapter1;   
import org.openqa.selenium.WebDriver;    
import org.openqa.selenium.firefox.FirefoxDriver;

public class NavigateToAUrl 
{
    public static void main(String[] args) 
    {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");

    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In my case it was caused by having different versions of selenium artifacts on the classpath.

I use gebish: org.grails.plugins:geb:1.1.1 which depends on:

  • org.seleniumhq.selenium:selenium-api:2.53.1
  • org.seleniumhq.selenium:selenium-remote-driver:2.53.1

on the other hand I tried to use org.seleniumhq.selenium:selenium-firefox-driver:3.4.0

After upgrading selenium-api, selenium-remote-driver and selenium-support to version 3.4.0 everything was fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...