我希望更新到selenium webdriver 3 beta 2以测试兼容性
Selenium WebDriver:3.0.0-beta2
Firefox:48.0
操作系统:Windows 7
代码:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class GeckDriverTest {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "src/test/resources/wires.exe");
// System.setProperty("webdriver.firefox.marionette", "src/test/resources/geckodriver.exe");
// System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", true);
cap.setCapability("firefox_binary", "firefoxbinarypath");
WebDriver browser=new FirefoxDriver(cap);
browser.get("http://www.seleniumhq.org/");
browser.findElement(By.linkText("Download")).click();
browser.close();
}
}
但是浏览器没有关闭。
如果我使用browser.quit()
它会关闭但是抛出错误:
1472391805470 Marionette INFO在端口56555上收听 1472391808818 Marionette INFO startBrowser 95d29b68-b0bb-487A-915C-4896cfaa09ee 1472391808831 Marionette INFO sendAsync 95d29b68-b0bb-487A-915C-4896cfaa09ee 1472391809520 Marionette INFO sendAsync 95d29b68-b0bb-487A-915C-4896cfaa09ee 1472391809653 Marionette INFO sendAsync 95d29b68-b0bb-487A-915C-4896cfaa09ee 1472391827467 Marionette INFO sendAsync 95d29b68-b0bb-487A-915C-4896cfaa09ee 1472391827483 Marionette INFO sendAsync 95d29b68-b0bb-487a-915c-4896cfaa09ee [Child 6088] ### !!!中止: 中止通道错误:文件 C:/builds/moz2_slave/m-rel-w64-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, 第2046行“main”中的异常 org.openqa.selenium.remote.UnreachableBrowserException:错误 与远程浏览器通信。它可能已经死了。构建信息: 版本:'未知',修订版:'31c43c8',时间:'2016-08-02 21:57:56 -0700'系统信息:主机:'mrunal-laptop',ip:'192.168.56.1',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1', java.version:'1.8.0_45'驱动程序信息:driver.version:RemoteWebDriver 功能[{rotating = false,raisesAccessibilityExceptions = false, marionette = true,appBuildId = 20160726073904,version =,platform = XP, proxy = {},command_id = 1,specificationLevel = 0, firefox_binary = “firefoxbinarypath”, acceptSslCerts = false,browserVersion = 48.0,platformVersion = 6.1, XULappId = {ec8030f7-c20a-464f-9b0e-13a3a9e97384},browserName = Firefox, takesScreenshot = true,takeElementScreenshot = true, platformName = Windows_NT,device = desktop}]会话ID: 95d29b68-b0bb-487a-915c-4896cfaa09ee at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:670) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:706) 在 org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:531) 在practise.GeckDriverTest.main(GeckDriverTest.java:20)引起: java.lang.IllegalStateException:Unix上不能使用UnixUtils 在 org.openqa.selenium.os.ProcessUtils.getProcessId(ProcessUtils.java:188) 在 org.openqa.selenium.os.UnixProcess $ SeleniumWatchDog.getPID(UnixProcess.java:222) 在 org.openqa.selenium.os.UnixProcess $ SeleniumWatchDog.access 300 $(UnixProcess.java:201) 在org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:132) 在org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155) 在 org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:196) 在 org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:94) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:649) ......还有3个
答案 0 :(得分:0)
尝试创建新的DesiredCapabilities
实例。
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
而不是
cap.setCapability("marionette", true);
cap.setCapability("firefox_binary", "firefoxbinarypath");