我正在學習硒,我剛從一個網站複製了一個簡單的java代碼並試圖運行它。但它給了我下面的錯誤。請幫我修復它。簡單的java代碼中的硒錯誤
安裝的文件:
1. Selenium api 2.44.0
2. Selenium firefox driver 2.44.0
3. Seleinium server stand alone 2.53.1
4. Selenium support 2.44
5. Firefox version - 35.1.0
錯誤:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/openqa/selenium/remote/internal/CircularOutputStream at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95) at Sel.OpenGoogle.main(OpenGoogle.java:6) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.internal.CircularOutputStream 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) ... 4 more
我的代碼:
添加硒遠程驅動器2.4.4Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'PC', ip: '192.168.1.2', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:72)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:59)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:55)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Sel.OpenGoogle.main(OpenGoogle.java:6)
後
package Sel;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class OpenGoogle {
public static void main(String args[]){
WebDriver driver=new FirefoxDriver();
System.out.println("Hello Google...");
driver.get("http://google.com");
}
}
錯誤
是的,我右鍵點擊我的項目,然後添加jar文件 –
你可以添加硒遠程驅動程序jar以及再次測試。 https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-remote-driver/2.7.0 –
後,我添加的遠程驅動器得到這個錯誤。更新OP –