-2
package org.example;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Sample {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("Webdriver.chrome.driver","C:\\Users\\Asus\\Downloads\\jar_files (1)\\selenium-chrome-driver-3.141.59");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.guru99.com");
        //driver.manage().window().maximize();
        Thread.sleep(5000);
        driver.quit();
        driver.close();
    }
}

With this code I get the following error:

"C:\Program Files\Java\jdk-13.0.1\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3\lib\idea_rt.jar=59685:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\Asus\Maven wokspace\target\classes;C:\Users\Asus.m2\repository\org\apache\poi\poi\3.12\poi-3.12.jar;C:\Users\Asus.m2\repository\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;C:\Users\Asus.m2\repository\org\apache\poi\poi-ooxml\3.12\poi-ooxml-3.12.jar;C:\Users\Asus.m2\repository\org\apache\poi\poi-ooxml-schemas\3.12\poi-ooxml-schemas-3.12.jar;C:\Users\Asus.m2\repository\org\apache\xmlbeans\xmlbeans\2.6.0\xmlbeans-2.6.0.jar;C:\Users\Asus.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;C:\Users\Asus.m2\repository\org\seleniumhq\webdriver\webdriver-common\0.9.7376\webdriver-common-0.9.7376.jar;C:\Users\Asus.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.141.59\selenium-chrome-driver-3.141.59.jar;C:\Users\Asus.m2\repository\org\seleniumhq\selenium\selenium-api\3.141.59\selenium-api-3.141.59.jar;C:\Users\Asus.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\3.141.59\selenium-remote-driver-3.141.59.jar;C:\Users\Asus.m2\repository\net\bytebuddy\byte-buddy\1.8.15\byte-buddy-1.8.15.jar;C:\Users\Asus.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\Asus.m2\repository\com\google\guava\guava\25.0-jre\guava-25.0-jre.jar;C:\Users\Asus.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\Asus.m2\repository\org\checkerframework\checker-compat-qual\2.0.0\checker-compat-qual-2.0.0.jar;C:\Users\Asus.m2\repository\com\google\errorprone\error_prone_annotations\2.1.3\error_prone_annotations-2.1.3.jar;C:\Users\Asus.m2\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;C:\Users\Asus.m2\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;C:\Users\Asus.m2\repository\com\squareup\okhttp3\okhttp\3.11.0\okhttp-3.11.0.jar;C:\Users\Asus.m2\repository\com\squareup\okio\okio\1.14.0\okio-1.14.0.jar;C:\Users\Asus.m2\repository\org\testng\testng\7.1.0\testng-7.1.0.jar;C:\Users\Asus.m2\repository\com\beust\jcommander\1.72\jcommander-1.72.jar;C:\Users\Asus.m2\repository\com\google\inject\guice\4.1.0\guice-4.1.0-no_aop.jar;C:\Users\Asus.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\Asus.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\Asus.m2\repository\org\yaml\snakeyaml\1.21\snakeyaml-1.21.jar" org.example.Sample

Exception in thread "main" java.lang.NoSuchFieldError: LINUX

at org.openqa.selenium.net.PortProber.(PortProber.java:43)

at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:351)

at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)

at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)

at org.example.Sample.main(Sample.java:8)

Process finished with exit code 1

Anybody tell me the exact solution?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Test
  • 11
  • 2

1 Answers1

0

This error message...

Exception in thread "main" java.lang.NoSuchFieldError: LINUX

...implies that the Platform.LINUX field in the source is absent.


It is also pretty much evident from the error trace logs that you are using and this error can happen in the following cases:

  • Old and incompatible binaries.
  • CLASSPATH conflict i.e. similar jar file already present with in the project.

Solution

You have to take care of a couple of things as follows:

  • You need to replace the caps W with small w as follows:

    "webdriver.chrome.driver"
    
  • As you are using Maven:

    • If you have added the selenium-chrome-driver dependency you don't need to use the System.setProperty() line.
    • You need to execute the following commands to flush out the previous dependencies, install the new dependencies & execute your test:

    mvn clean mvn install mvn test

    • In a worst case scenario you may have delete the .m2 i.e. MAVEN_HOME sub-directory and re-install the dependencies to execute your test.

Further, ensure that:

  • JDK is upgraded to current levels JDK 8u222.
  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
  • Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352