Issue while trying to run Selenium

2019-04-09 13:10发布

问题:

I am using Ubuntu 12.04 and trying to run Selenium, with the command

webdriver-manager start

but I keep getting

webdriver-manager start
seleniumProcess.pid: 3522
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncher : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.openqa.grid.selenium.GridLauncher. Program will exit.
Selenium Standalone has exited with code 1

I installed it doing

sudo npm install –g protractor
webdriver-manager update

How can I fix this issue and run the Selenium server.

回答1:

Unsupported major.minor version error usually occurs due to running a java program which is compiled under a newer java version than the running java version. most probably the selenium version which you are using is compiled from a newer java version than your installed java version.

Please check your java version and upgrade to latest java version.

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version