2015-09-14 30 views
1

我試圖在Firefox爲什麼我無法處理兩個瀏覽器?

public class flip 
{ 
    static WebDriver driver = new FirefoxDriver(); // starting firefox 

    public static void main(String[] args) throws IOException, InterruptedException 
    { 
     System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe"); 
     WebDriver driver1 = new ChromeDriver(); 

     driver1.get("website1"); 
     driver1.findElement(By.id("id_username")).sendKeys("username"); 
     driver1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); 
     driver1.findElement(By.id("id_password")).sendKeys("password"); 
     System.out.print("logged in"); 
     driver1.close(); 

     driver.get("website-2"); // in firefox 
    } 
}   

我正在運行谷歌Chrome和代碼的一部分,其餘以下錯誤(當程序需要切換瀏覽器)。 兩個瀏​​覽器都打開,但無法開車。

Exception in thread "main" org.openqa.selenium.WebDriverException: 
    f.QueryInterface is not a function 
    Command duration or timeout: 60.03 seconds 

任何一個可以幫助我在哪裏出錯了? (firefox webdriver必須是靜態的..)

+0

夫婦的事情......我會建議你更清楚地命名你的驅動變量......像firefoxDriver和chromeDriver。這樣就很清楚你在駕駛哪個瀏覽器。您沒有指定錯誤在哪一行。 'driver1.close;'應該是'driver1.close();' – JeffC

+0

waht是你的硒和firefox版本。他們之間有衝突 –

+0

@mahsumAkbas Firefox 40.03和Selenium 2.47.1 – Ravichandra

回答

1

把http://放在你的firefox驅動程序的網址上。這是硒版本的義務。

+0

謝謝兄弟的工作 – Ravichandra

相關問題