java.lang.UnsupportedClassVersionError:org/openqa/selenium/WebDriver:Java 7的Selenium不支持的major.minor 52.0版本错误 [英] java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 52.0 error with Selenium through Java 7
问题描述
这是打开chrome浏览器并关闭它的硒代码.
This is the code of selenium code to open the chrome browser and closing it.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
public class TC001_Login_Logout
{
public static void main(String args[]) throws Exception
{
System.setProperty("webdriver.chrome.driver", "C:\\Eclipse\\Selenium\\chrome");
WebDriver driver = new ChromeDriver();
driver.get("http://127.0.0.1/orangehrm-2.6/login.php");
System.out.println("Application opened");
driver.findElement(By.name("txtUserName")).sendKeys("admin");
driver.findElement(By.name("txtPassword")).sendKeys("admin");
driver.findElement(By.name("Submit")).click();
Thread.sleep(3000);
System.out.println("Login completed");
driver.findElement(By.linkText("Logout")).click();
System.out.println("Logout completed");
driver.close(); //close browser
}
}
运行上述程序后,我得到了运行时异常.我的系统中安装了Java jdk version7.我如何摆脱这个错误.需要你们的帮助.这是我的第一个硒程序.
After running the above program I am getting run time exception. I have java jdk version7 installed in my system. How can i get rid of this error. Need help from you guys. This is my first selenium program.
错误消息:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver :
Unsupported major.minor version 52.0 (lines)---> 1.at java.lang.ClassLoader.defineClass1(Native Method) 2.atjava.lang.ClassLoader.defineClass(UnknownSource)atjava.security.SecureClassLoader.defineClass(Unknon Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source)at java.net.URLClassLoader$1.run(Unknown Source)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(Unknown Source)atjava.lang.ClassLoader.loadClass(UnknownSource)atsun.misc.Launcher$AppClassLoader.loadClass(Unkown Source) at java.lang.ClassLoader.loadClass(Unknown Source)atjava.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getMethod0(Unknown Source)at java.lang.Class.getMethod(Unknown Source)at sun.launcher.LauncherHelper.getMainMethod(Unknown Source).
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
推荐答案
此错误消息...
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 52.0
...描述org/openqa/selenium/WebDriver
类文件与之兼容的JRE版本,即 major.minor version 52.0
...describes the version of the JRE with which the org/openqa/selenium/WebDriver
class file is compatible with i.e. major.minor version 52.0
根据 Wikipedia-Java类文件,已发布的编号为:
As per Wikipedia - Java class file the published numbers are:
Java SE 14 = 58 (0x3A hex)
Java SE 13 = 57 (0x39 hex)
Java SE 12 = 56 (0x38 hex)
Java SE 11 = 55 (0x37 hex)
Java SE 10 = 54 (0x36 hex)
Java SE 9 = 53 (0x35 hex)
Java SE 8 = 52 (0x34 hex)
Java SE 7 = 51 (0x33 hex)
Java SE 6.0 = 50 (0x32 hex)
Java SE 5.0 = 49 (0x31 hex)
JDK 1.4 = 48 (0x30 hex)
JDK 1.3 = 47 (0x2F hex)
JDK 1.2 = 46 (0x2E hex)
JDK 1.1 = 45 (0x2D hex)
正如您在有关使用 ... java jdk version7 ... 的问题中已经提到的那样,因此您会看到错误.
As you have already mentioned in your question about using ...java jdk version7..., hence you see the error.
由于编译org/openqa/selenium/WebDriver
类文件的最低要求是 Java 8
,因此必须将 JDK 升级到相同级别,最好升级到当前的 JDK 8u222 .
As the minimum requirement to compile org/openqa/selenium/WebDriver
class file is Java 8
you have to upgrade JDK to the same level, preferably at current level of JDK 8u222.
这篇关于java.lang.UnsupportedClassVersionError:org/openqa/selenium/WebDriver:Java 7的Selenium不支持的major.minor 52.0版本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!