2016-10-18 43 views
11

Selenium 3.0 Firefx驅動程序因org.openqa.selenium.SessionNotCreatedException失敗:無法創建新的遠程會話。Selenium 3.0 Firefx驅動程序因org.openqa.selenium.SessionNotCreatedException失敗:無法創建新的遠程會話

System.setProperty("webdriver.gecko.driver", "..<Path>../geckodriver.exe"); 
capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 
driver = new FirefoxDriver(capabilities); 


Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, [email protected]3a, browserName=firefox, moz:[email protected]3a, version=, platform=ANY}], required capabilities = Capabilities [{}] 
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700' 
System info: host: 'D202540', ip: '10.22.19.193', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45' 
Driver info: driver.version: FirefoxDriver 
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) 
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:135) 
+0

同樣的情況在linux上尋找解決方案 – lese

+0

你是怎麼解決它的@lese? – Emna

+0

使用Selenium Webdriver 3.3.1和Geckodricer v0.15 –

回答

1

您需要下載geckodriver。然後設置

System.setProperty("webdriver.gecko.driver", "path\\to\\geckodriver.exe") 

檢查這個link

+0

已解決此問題我正在設置系統屬性,但仍然出現錯誤,System.setProperty(「webdriver.gecko.driver」,「..」 ../geckodriver 。可執行程序」); capabilities = DesiredCapabilities.firefox(); 功能。setCapability(「marionette」,true); driver = new FirefoxDriver(功能); – KingArasan

+0

你如何寫geckodriver.exe的路徑? –

+0

路徑格式應該是「D:\\ work \\ project \\ geckodriver.exe」。如果你只是按照上面所寫的那樣設置路徑,它將不起作用。 –

0

對於遠程應該不使用遠程驅動程序呢?

但我也越來越類似的錯誤下面的配置:

System.setProperty("webdriver.gecko.driver", "src\\test\\resources\\webdrivers\\geckodriver.exe"); 

    port = ":4444"; 
    node_ip_address = "http://" + node_ip_address + port + "/wd/hub" ; 

    DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
    capabilities.setBrowserName("firefox"); 
    //capabilities.setVersion(""); 

    capabilities.setCapability("marionette", true); 
    driver = new RemoteWebDriver(new URL(node_ip_address), capabilities); 
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
    driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); 
0

我有同樣的問題,這個固定它。看來它找不到Firefox二進制文件

capabilities.setCapability("firefox_binary","C:\\Program Files\\Mozilla Firefox\\firefox.exe"); 
0

這裏同樣的問題。它解決了以管理員權限打開Eclipse/Netbeans的問題。

0

這個工作(Linux Mint的,openSUSE的thumbleweed,WIN7) 與

libraryDependencies += "org.seleniumhq.selenium" % "selenium-firefox-driver" % "3.0.1"

geckodriver.exe -V geckodriver 0.13.0

if (System.getProperty("os.name").toLowerCase().contains("linux")) { 
    println("загружены настройки os.name=linux") 
    System.setProperty("webdriver.chrome.driver", "bin/chromedriver") 
    System.setProperty("webdriver.gecko.driver", "bin/geckodriver") 

}else{ 
    System.setProperty("webdriver.chrome.driver", "bin\\chromedriver.exe") 
    System.setProperty("webdriver.gecko.driver", "bin\\geckodriver.exe") 
    System.setProperty("webdriver.ie.driver", "bin\\IEDriverServer.exe") 
    System.setProperty("webdriver.edge.driver", "C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe") 
    System.setProperty("webdriver.opera.driver", "c:\\XXX\\operadriver.exe") 

    System.setProperty("webdriver.opera.path","""C:\\Users\\user\\AppData\\Local\\Programs\\Opera""") 
    System.setProperty("webdriver.opera.binary","""C:\\Users\\user\\AppData\\Local\\Programs\\Opera\\launcher.exe""") 
    // 
} 

...

 case 
     "firefox" => { 
     println(" подгружаем Веб-драйвер: geckodriver") 
     //iniprofile = new ProfilesIni() 
     //ffprofile = iniprofile.getProfile("default") 
     dc = DesiredCapabilities.firefox() 
     dc.setCapability("gecko", true) // как выйдет драйвер, так и установить 
//  dc.setCapability(FirefoxDriver.PROFILE, ffprofile); //FirefoxDriver.PROFILE = 「firefox_profile」; 
     remote = new FirefoxDriver(dc) 
     } 

,但對於Remotewebdriver連接,如果以前的會話失敗,取消或中止我們得到錯誤:

[info] XXXX.E011_WebDB6292 *** ABORTED *** 
[info] org.openqa.selenium.SessionNotCreatedException: Session is already started (WARNING: The server did not provide any stacktrace information) 
[info] Command duration or timeout: 0 milliseconds 
[info] Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700' 
[info] System info: host: 'XXXX', ip: '172.16.4.125', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_11' 
[info] Driver info: driver.version: RemoteWebDriver 
[info] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
0

今天我遇到了同樣的問題,看起來不是我的筆記本電腦上的管理員實際上是一個問題。要解決這個問題

  • 安裝在非管理方式火狐(只需要當Windows要求權限提升到沒有點擊)
  • 使用exe文件路徑(我的系統類似C:\\Users\\MyUserName\\AppData\\Local\\MozillaFirefox\\firefox.exe)。

    它實際上解決了這個問題。

5

這個問題的解決,是geckodriver 0.15和硒3.3版本。

+0

這讓我意識到對於geckodriver 0.17你需要Selenium 3.4.0 –

相關問題