Trying to run a simple Selenium signup test ERROR

Getting this error while running a simple test.

> java -version  
java version "1.8.0_102"

> compiler version javac -version  
javac 1.8.0_102

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 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) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at 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.Cla ss.getMethod0(Class.java:2856) at java.lang.Class.getMethod(Class.java:1668) at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)

Here's the code

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();

Had same issue. Removed older Java JDKs from the system, set to build with Java8 and worked like magic.


I am getting "Access Denied" error after website open. Still try if below code works for you -

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 JAR32 bitBrowserDrivers" + "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();
    }
}
链接地址: http://www.djcxy.com/p/38884.html

上一篇: TestFX是否与Java 7兼容?

下一篇: 尝试运行简单的Selenium注册测试错误