简单的selenium代码中的错误消息

时间:2017-01-07 05:25:06

标签: java selenium firefox

我正在努力学习硒。所以我安装了以下工具:

  • Firefox V 31
  • 硒火狐-驾驶员2.0b3

我使用下面的代码运行它并收到错误消息。不确定这意味着什么。任何帮助都会很好。

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

public class Sele {

/**
 * @param args
 */
public static void main(String[] args) {
    // Create webDriver reference
    WebDriver driver;

    // Launch FirefoxDriver
    driver = new FirefoxDriver();

    // Open the web page
    driver.get("http://google.com");

    // Enter the text in the search box
    WebElement searchText = driver.findElement(By.name("q"));
    searchText.sendKeys("FirefoxDriver");

    // Close the driver
    driver.quit();

}

}

错误讯息:

Exception in thread "main" java.lang.NoClassDefFoundError:       org/openqa/selenium/RenderedWebElement
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown 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)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at Sele.main(Sele.java:17)
Caused by: java.lang.ClassNotFoundException:     org.openqa.selenium.RenderedWebElement
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more

1 个答案:

答案 0 :(得分:0)

看起来你的主要site解释了你需要安装selenium服务器,而不仅仅是浏览器驱动程序。