提问人:Farhood Naqizadeh 提问时间:8/10/2023 更新时间:8/10/2023 访问量:131
Chrome 无法启动:异常退出。(未知错误:DevToolsActivePort 文件不存在) 在 java 中
Chrome failed to start: exited abnormally .(unknown error: DevToolsActivePort file doesn't exist) in java
问:
您好,我在 ubuntu 上使用 selenium 和 java,我为 glassfish 创建了一个用户并在其上运行 glassfish,我用于 chrome 115 的 selenium 版本和 chrome,但是当我启动 selenium 时,错误显示:
"Unknown Computer","127.0.1.1","Linux 5.4.0-155-generic, architecture: amd64-64","glassfishuser","Cbc","0.1.0 nightly","Java version 17.0.8",FATAL,41395277,2023-08-10 10:42:22.771 IRST,ir.mehritco.megnatis.cbc.CbcRobot.<init>(CbcRobot.java:49),"We have problem with instance chrome Driver : Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Host info: host: 'srv2851084109', ip: '127.0.1.1'
Build info: version: '4.11.0', revision: '040bc5406b'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-155-generic', java.version: '17.0.8'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--remote-allow-origins=*, --user-data-dir=/home/glass..., user-agent=Mozilla/5.0 (Win..., --lang=en-GB, --disable-dev-shm-usage, --ignore-certificate-errors, --disable-gpu, start-maximized, --no-sandbox, disable-infobars, --disable-extensions, --enable-sandbox], excludeSwitches: [enable-automation], extensions: [], useAutomationExtension: false}}]}]",,,"",,"",
"Unknown Computer","127.0.1.1","Linux 5.4.0-155-generic, architecture: amd64-64","glassfishuser","Cbc","0.1.0 nightly","Java version 17.0.8",INFO,41395278,2023-08-10 10:42:22.772
位于以下位置的 chrome : /opt/google/chrome/chrome 如果在终端中执行,则可以工作。 这是来自我的日志服务器的日志。Selenium 的选项是:
public final ChromeDriver headless(String profileLocation) {
ChromeOptions options = new ChromeOptions();
options.addArguments("--user-data-dir=" + profileLocation);//#e.g. C:\Users\You\AppData\Local\Google\Chrome\User Data
options.setCapability(ChromeOptions.CAPABILITY, options);
options.addArguments(userAgent[1]);
options.addArguments("--lang=en-GB");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
//https://stackoverflow.com/questions/63649026/how-to-disable-remove-the-chrome-headless-disclaimer-in-selenium-and-java
options.addArguments("--ignore-certificate-errors");
System.setProperty("java.awt.headless", "false");
//https://www.selenium.dev/blog/2023/headless-is-going-away/
// options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("start-maximized");
// options.addArguments("--window-size=1400,800");
options.addArguments("--no-sandbox"); // Bypass OS security model
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
options.addArguments("--enable-sandbox");
return new ChromeDriver(options);
}
并且无头模式已关闭(无头==false)。 但是错误继续存在,所有应用程序都无法运行。
我从系统属性添加了 chrome 驱动程序。
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
答: 暂无答案
评论