gpt4 book ai didi

java - Firefox 无法在 VM 机器中启动

转载 作者:行者123 更新时间:2023-12-01 13:45:42 28 4
gpt4 key购买 nike

我正在使用以下代码在本地和通过 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"
}
]
}
}

最佳答案

需要更多输入.. 看起来是网络问题,您的代码主机无法访问集线器。

请让我知道:-

  • 集线器 VM 位于何处,如果它在同一台机器上,请使用 IP 桥接配置而不是 NAT。
  • 你的机器有代码和集线器在同一个 VLAN 上。
  • 节点在哪里?您不会在 Hub 上看到浏览器启动。它将在节点上。
  • getNodeUrl() 返回集线器机器的 IP。
  • 集线器和节点上的防火墙以及代码主机关闭(只是为了确保它不会阻止连接)

  • 其余代码看起来不错。

    关于java - Firefox 无法在 VM 机器中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61365436/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com