2014-03-18 22 views
0

我無法從我設置的Java項目中識別ChromeDriver和IEDriverServer。可執行文件已被下載並添加到C:\ Tools \ selenium \ drivers中,並已添加到路徑變量(Windows)中。當我嘗試過如何運行下面的代碼:使webdriver可執行文件與Java協同工作的錯誤

import org.openqa.selenium.By; 

import org.openqa.selenium.support.ui.ExpectedConditions; 
import org.openqa.selenium.support.ui.WebDriverWait; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
//import org.openqa.selenium.firefox.FirefoxDriver; 
//import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.ie.InternetExplorerDriver; 

public class MarketLeaderHomePage { 
    public static void main(String[] args) throws Exception { 
     //WebDriver driver = new FirefoxDriver(); 

     WebDriver driver = new InternetExplorerDriver(); 


     driver.get("myURL"); 

我得到的錯誤「以必須由webdriver.ie.driver系統屬性設置的驅動程序可執行文件的路徑;」。我可以設置屬性來明確指定驅動程序路徑,但我的理解是如果驅動程序exes被添加爲我不應該這樣做的路徑的一部分。我是Java的新手,所以我想知道是否有某些我缺少的關於包或Eclipse IDE需要完成的事情?

回答

0

InternetExplorerDriver是一個獨立的服務器,它實現了WebDriver的有線協議 。您無需在使用InternetExplorerDriver的 之前運行安裝程序,但某些配置需要使用 。獨立服務器可執行文件必須從 下載頁面下載並放置在PATH中。

請檢查this thread。鉻也一樣,它也是一個獨立的,reference

+0

@Erik-謝謝,但這不是問題。我意識到驅動程序都是獨立的,我已經將它們解壓到一個目錄中並將其添加到目錄中。除非使用System.setProperty方法明確指定驅動程序的路徑,否則我仍然會收到錯誤。我的理解是,可執行文件在我不應該在代碼中指定它們的路徑中。 –

相關問題