簡體   English   中英

簡單java代碼中的Selenium錯誤

[英]Selenium error in simple java code

我正在學習selenium,我只是從網站上復制了一個簡單的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

錯誤:

線程“main”java.lang.NoClassDefFoundError中的異常:
Org / openqa / selenium / remote / internal / CircularOutputStream org.openqa.selenium.firefox.FirefoxBinary。(FirefoxBinary.java:59)org.openqa.selenium.firefox.FirefoxBinary。(FirefoxBinary.java:55)at org。 Sel.OpenGoogle.main(OpenGoogle.java:6)中的openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:95)引起:java的java.lang.ClassNotFoundException:org.openqa.selenium.remote.internal.CircularOutputStream位於java.lang.ClassLoader.loadClass(未知來源)的.net.URLClassLoader.findClass(未知來源)位於sun.misc.Launcher $ appClassLoader.loadClass(未知來源),位於java.lang.ClassLoader.loadClass(未知來源)..還有4個

我的代碼:

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");    
    }  
 } 

添加selenium遠程驅動程序2.4.4后出錯

Exception 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)

@Stack Mark從此鏈接下載selenium 2.53 for java

http://selenium-release.storage.googleapis.com/index.html?path=2.53/

刪除所有當前安裝的jar文件並加載新文件。 注意不要刪除JRE系統庫。 一切都會好起來的。 你使用firefox瀏覽器的方式? 我正在使用47.0.1好處是你不必使用gecko驅動程序。

OpenGoogle.java

您的代碼在我的系統上正常運行。 您最好檢查jdk的類路徑。 希望這可以幫助。 :)除了檢查這些。 http://www.codegravity.com/blog/exception-in-thread-main-java-lang-noclassdeffounderror

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM