我在一个实现了Selenium chromedriver的远程服务器上运行Apache Tomcat/10.0.23中的java webapp。每当我创建webdriver时,它都会返回HTTP状态500 -内部服务器错误。
谷歌浏览器位置:
/usr/bin/google-chrome /usr/share/man/man1/google-chrome.1.gz
谷歌 chrome 版:
110.0.5481.77
Chrome驱动程序位置:
/usr/bin/chromedriver
Chrome驱动程序版本:
110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839})
selenium
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.8.0</version>
</dependency>
错误:
<body>
<h1>HTTP Status 500 – Internal Server Error</h1>
<hr class="line" />
<p><b>Type</b> Exception Report</p>
<p><b>Message</b> Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start:
crashed.</p>
<p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.
</p>
<p><b>Exception</b></p>
<pre>org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Host info: host: 'ip-xxxxxxxxxx2', ip: '127.0.0.1'
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-21-cloud-amd64', java.version: '11.0.15.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless=new, --disable-dev-shm-usage, --no-sandbox], extensions: []}, pageLoadStrategy: eager}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless=new, --disable-dev-shm-usage, --no-sandbox], extensions: []}, pageLoadStrategy: eager}}]
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:148)
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106)
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:229)
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:101)
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:82)
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:71)
com.fourdcontrols.servlets.TestServlet.doGet(TestServlet.java:29)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:668)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
</pre>
<p><b>Note</b> The full stack trace of the root cause is available in the server logs.</p>
<hr class="line" />
<h3>Apache Tomcat/10.0.23</h3>
</body>
日志:
Starting ChromeDriver 110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839}) on port 3125
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
1条答案
按热度按时间uxhixvfz1#
一个月一个月
A common cause for Chrome to crash during startup is running Chrome as **
root** user (**
administrator**) on Linux. While it is possible to work around this issue by passing
--no-sandboxflag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.
参考文献
您可以在以下位置找到一些相关的详细讨论和文档: