2010-08-17 13 views
8

मैं selenium-java-2.0a5.zipjava.lang.ClassNotFoundException: WebDriver एपीआई

http://code.google.com/p/selenium/downloads/list

डाउनलोड किया है और निम्नलिखित कोड भाग गया:

package org.openqa.selenium.example; 

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.htmlunit.HtmlUnitDriver; 

public class Example { 
    public static void main(String[] args) { 
     // Create a new instance of the html unit driver 
     // Notice that the remainder of the code relies on the interface, 
     // not the implementation. 
     WebDriver driver = new HtmlUnitDriver(); 

     // And now use this to visit Google 
     driver.get("http://www.google.com"); 

     // Find the text input element by its name 
     WebElement element = driver.findElement(By.name("q")); 

     // Enter something to search for 
     element.sendKeys("Cheese!"); 

     // Now submit the form. WebDriver will find the form for us from the element 
     element.submit(); 

     // Check the title of the page 
     System.out.println("Page title is: " + driver.getTitle()); 
    } 
} 

लेकिन फिर मैं

मिला
at org.openqa.selenium.example.Example.main(Example.java:13) 
Caused by: java.lang.ClassNotFoundException: com.gargoylesoftware.htmlunit.WebWindowListener 
    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) 
    ... 1 more 

क्या मुझे एक कदम याद आया? मैंने परियोजना में सेलेनियम-जावा-2.0a5.jar आयात करना सुनिश्चित किया है।

+0

मेरा जवाब जांचें। आप क्लासपाथ में HtmlUnit के जार को जोड़ना भूल गए। – YoK

उत्तर

10

htmlunit jar क्लासपाथ में नहीं है। सेलेनियम-जावा-2.0 ए 5.जर के निर्भरता lib jars भी शामिल करें। मुझे यकीन है कि उन्हें डाउनलोड किए गए ज़िप में

2

आप प्रोजेक्ट में "HtmlUnit" का उपयोग करते हैं और इसका जार क्लासपाथ से गुम है। इसे अपने प्रोजेक्ट गुणों में जोड़ें क्योंकि आपने सेलेनियम जोड़ा है।

संबंधित मुद्दे