试图运行一个简单的Selenium注册测试错误

时间:2016-09-11 23:17:46

标签: java selenium unsupported-class-version

运行简单测试时出现此错误。

> java -version  
java version "1.8.0_102"

> compiler version javac -version  
javac 1.8.0_102
  

线程“main”中的异常java.lang.UnsupportedClassVersionError:org / openqa / selenium / WebDriver:不支持的major.minor版本52.0   at java.lang.ClassLoader.defineClass1(Native Method)       at java.lang.ClassLoader.defineClass(ClassLoader.java:800)       at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)       at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)       在java.net.URLClassLoader.access $ 100(URLClassLoader.java:71)       在java.net.URLClassLoader $ 1.run(URLClassLoader.java:361)       在java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)       at java.security.AccessController.doPrivileged(Native Method)       在java.net.URLClassLoader.findClass(URLClassLoader.java:354)       at java.lang.ClassLoader.loadClass(ClassLoader.java:425)       at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:308)       at java.lang.ClassLoader.loadClass(ClassLoader.java:358)       at java.lang.Class.getDeclaredMethods0(Native Method)       at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)       at java.lang.Class.getMethod0(Class.java:2856)       在java.lang.Class.getMethod(Class.java:1668)       在sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)       at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)

这是代码

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class CustomerSignUpTest {

    public static void main(String[] args) {
        WebDriver selenium = new ChromeDriver();
        selenium.get("http://www.cvs.com");
        WebElement signuplink = null;
        signuplink.findElement(By.partialLinkText("singup"));
        WebElement Clicklink = null;
        Clicklink.click();

2 个答案:

答案 0 :(得分:0)

有同样的问题。从系统中删除了旧的Java JDK,设置为使用Java8构建并像魔术一样工作。

答案 1 :(得分:0)

我得到了#34;访问被拒绝"网站打开后出错。如果下面的代码适合您,请继续尝试 -

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;

import java.io.IOException;

public class test {
    @SuppressWarnings("null")
    public static void main(String[] args) {

        String Browser_Full_path = Driver.APP_PATH + "\\Support JAR\\32 bit\\BrowserDrivers\\" + "chromedriver.exe";
        System.out.println(" browser full path => " + Browser_Full_path);
        System.setProperty("webdriver.chrome.driver", Browser_Full_path);
        ChromeDriverService cds = ChromeDriverService.createDefaultService();
        try {
            cds.start();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--start-maximized");
        WebDriver driver = new ChromeDriver(options);

        driver.get("http://www.cvs.com");
        WebElement signuplink = null;
        signuplink.findElement(By.partialLinkText("signup"));
        WebElement Clicklink = null;
        Clicklink.click();
    }
}