Java、Selenium、Debian for Raspberry Pi 4、geckodriver 错误打印垃圾

Java, Selenium, Debian for Raspberry Pi 4, geckodriver error prints garbage

我正在制作一个使用 Selenium 访问网页和检索数据的 Java 程序,它适用于 Windows、纯 Debian 和 Ubuntu 但是当我 运行 它在我的 Raspberry Pi 4 的 Debian 的 RPI4 上,geckodriver 给出了神秘的错误并且程序崩溃了。

报错如下:

/usr/local/bin/geckodriver: 2: /usr/local/bin/geckodriver: YM9sHIiHMIi԰: not found
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: Syntax error: end of file unexpected (expecting ")")
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: 6: not found
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: : not found
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: : not found
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: 6: not found
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: $/: not found
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: GNUu¬wת,岹PXH: not found
/usr/local/bin/geckodriver: 1: /usr/local/bin/geckodriver: ELF: not found
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29555
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'raspy', ip: '192.168.1.33', os.name: 'Linux', os.arch: 'aarch64', os.version: '5.9.0-0.bpo.5-arm64', java.version: '11.0.9.1'
Driver info: driver.version: FirefoxDriver
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
        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.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
        at net.ddns.creepercrack.Main.main(Main.java:40)
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29555
        at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
        at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:165)
        at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
        at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
        at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
        at okhttp3.RealCall.execute(RealCall.java:77)
        at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:103)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:105)
        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)
        ... 5 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
        at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
        at java.base/java.net.Socket.connect(Socket.java:609)
        at okhttp3.internal.platform.Platform.connectSocket(Platform.java:129)
        at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:245)
        ... 27 more

该程序还创建了这个文件:''$'[=13=]12[=13=]2''@@'$'04''y@8'$'\a''@'$'52[=13=]1[=13=]5''@@t'$'2''6t'$'2''6',但我自己没有编写该文件。程序运行时不会出现这种情况,只有当程序崩溃时才会出现这种情况。

可能是它不起作用,但我想知道答案。 geckodriver 正确地在程序内的 PATH 中并且是可执行的 另外,firefox-esr 和 default-jre。

  1. 关于使用时打印的“乱码”
    'gekodriver',可能是因为它不适用于平台
    (硬件+operating_system)你正在使用?
  2. 关于

Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29555 Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: 'raspy', ip: '192.168.1.33', os.name: 'Linux', os.arch: 'aarch64', os.version: '5.9.0-0.bpo.5-arm64', java.version: '11.0.9.1'

这表明在 tcp6 ip 协议上没有监听 29555。

以上只是猜测,您可以尝试调查,直到出现更知情的人。