2017-06-01 82 views
0

我正嘗試使用以下代碼啓動Firefox瀏覽器;org.openqa.selenium.SessionNotCreatedException無法啓動瀏覽器\? C: Program Files Mozilla Firefox firefox.exe:其他操作系統錯誤

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.testng.annotations.Test; 

public class test00104 { 

    @Test 

    public void testerror15() throws InterruptedException{ 
     System.setProperty("webdriver.gecko.driver","D:\\WorkSpace_Shweta\\UIAutomation\\lib\\geckodriver.exe"); 
     //System.setProperty("webdriver.firefox.bin","C:\\Program Files\\Mozilla Firefox\\firefox.exe"); 
     WebDriver driver = new FirefoxDriver(); 
     driver.get("https://www.google.com"); 
     Thread.sleep(2000); 
     driver.findElement(By.xpath("http://www.google.com")).sendKeys("Selenium hq"); 
    } 
} 

不知怎的,它不工作,我得到的錯誤是:

org.openqa.selenium.SessionNotCreatedException Failed to start browser \\?\C:\Program Files\Mozilla Firefox\firefox.exe: other os error.

我看到一些文章,但沒有找到答案。 使用環境:Selenium 3.4.0,Gecko 0.16.0和FF 53.0.3

回答

0

我有一個類似的問題,這是由於/tmp的配額被超過導致geckodriver無法創建Rust配置文件目錄(rust_mozprofile*)。

您可以使用TEMP環境變量爲這些配置文件指定不同的位置(請參見https://github.com/mozilla/geckodriver/issues/299)。此外,請確保使用driver.quit()正確關閉驅動程序,以防止配置文件填滿您的TEMP

相關問題