我正在使用以下代码在本地和通过 VM 机器启动 Firefox。但是我无法通过 VM 机器启动 Firefox。
case FIREFOX:
browserType = BrowserTypes.FIREFOX;
System.setProperty("webdriver.gecko.driver", "Drivers/geckodriver.exe");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability("marionette", true);
firefoxOptions.setAcceptInsecureCerts(true);
if(isRemote) {
webDriver = launchGridDriver(firefoxOptions, configProps.getNodeUrl());
Reporter.log("Running test on Grid, in browser \'Firefox\'", true);
} else {
webDriver = new FirefoxDriver(firefoxOptions);
Reporter.log("Running test in browser \'FIREFOX\'", true);
}
break;
private WebDriver launchGridDriver(Capabilities capabilities, String url){
try{
return new RemoteWebDriver(new URL(url), capabilities);
} catch(Exception e){
Reporter.log("There was an error setting up the remote WebDriver.");
e.printStackTrace();
return null;
}
}
我能够在本地启动 firefox,当我只是尝试在远程启动时出现以下错误。
org.openqa.selenium.SessionNotCreatedException: Unable to create session from {
"desiredCapabilities": {
"browserName": "firefox",
"server:CONFIG_UUID": "02c53809-74d8-4b47-95a1-fc97610ba78c",
"moz:firefoxOptions": {
"args": [
],
"prefs": {
}
},
"marionette": true,
"acceptInsecureCerts": true
},
"capabilities": {
"firstMatch": [
{
"acceptInsecureCerts": true,
"browserName": "firefox",
"moz:firefoxOptions": {
"args": [
],
"prefs": {
}
},
"server:CONFIG_UUID": "02c53809-74d8-4b47-95a1-fc97610ba78c"
}
]
}
}
最佳答案
需要更多输入.. 看起来是网络问题,您的代码主机无法访问集线器。
请让我知道:-
其余代码看起来不错。
关于java - Firefox 无法在 VM 机器中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61365436/