开发者社区> 问答> 正文

java selenium运行报错 Cannot assign requested address

完整报错: Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003}) on port 1724

Only local connections are allowed.

Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

[1583808944.224][SEVERE]: bind() failed: Cannot assign requested address (99)

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist

Build info: version: 'unknown', revision: 'unknown', time: 'unknown'

System info: host: 'iiiiiiiizzzzzzzz', ip: '111.11.111.111', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-174-generic', java.version: '11.0.1'

Driver info: driver.version: ChromeDriver

remote stacktrace: #0 0x5595dbb146e9

    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
    at main.main(main.java:19)

chromedriver无法开启。

经检查chromedriver与chrome版本匹配;代码中已加入headless和sandbox。

不知道哪里出了问题,求大家帮忙看看

展开
收起
游客kykuw2hx3zzuy 2020-03-10 11:04:04 1864 0
1 条回答
写回答
取消 提交回答
  • 问题已解决 之前安装chrome后,修改了一点东西,如下: ———————————————————— 输入 vim /usr/bin/google-chrome 打开后,在下列语句中添加 --user-data-dir exec -a "$0" "$HERE/chrome" "$@" --user-data-dir --no-sandbox ———————————————————— 去掉--user-data-dir后,这个问题就解决了,但是具体原因还不清楚

    2020-03-11 15:24:04
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载