Search code examples
javaseleniumnosuchfieldexception

java.lang.NoSuchFieldError: INSTANCE - WebDriver


I get following error message, when I try to execute test. There weren't any changes in version numbers in pom file, so we could exclude dependency related problems.

java.lang.NoSuchFieldError: INSTANCE

at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:144) at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)

driver = new FirefoxDriver(new FirefoxBinary(new File(FF_EXEPATH)), profile);

Solution

  • You are definitely have a version mismatch.

    Please ensure that you are resolving to

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    

    The easiest of trying to check if this is the root cause is to add this above dependency explicitly and see if that helps. Selenium is depending on httpclient 4.5.2.

    Just to check what version of httpclient are you resolving to, you can try running mvn dependency:tree | grep 'httpclient'. You should see something like below :

    09:40 $ mvn dependency:tree | grep 'httpclient'
    [INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
    ✔ ~/githome/PlayGround/testbed