java - UnreachableBrowserException - 在 OrangePiOne 上使用 PhantomJS 和 java 时 (Ubuntu 18.04.2)

标签 java forms phantomjs orange-pi

我想使用 PhantomJS 用我的小型 java 程序在网站上填写 html 表单。它在我的 Win 10 机器上经过测试,运行完美。我还想在我的 OrangePiOne(Armbian 5.85 和 Ubuntu 18.04.2) 上运行它。每次运行该程序时,我都会遇到以下异常:

Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: /home/ma/java_crontab_apps/phantomjs
Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 11594
Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=11594, --webdriver-logfile=/home/ma/java_crontab_apps/phantomjsdriver.log]
Oct 10, 2019 10:24:07 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
/home/ma/java_crontab_apps/phantomjs: 2: /home/ma/java_crontab_apps/phantomjs: Syntax error: word unexpected (expecting ")")
ERROR org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'orangepione', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.19.38-sunxi', java.version: '11.0.2'
Driver info: driver.version: PhantomJSDriver
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'orangepione', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.19.38-sunxi', java.version: '11.0.2'
Driver info: driver.version: PhantomJSDriver
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
        at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
        at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
        at com.example.suche.PhantomJsFormFill.createDriver(PhantomJsFormFill.java:76)
        at com.example.suche.PhantomJsFormFill.<init>(PhantomJsFormFill.java:32)
        at com.example.suche.Suche.main(Suche.java:98)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'orangepione', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.19.38-sunxi', java.version: '11.0.2'
Driver info: driver.version: PhantomJSDriver
        at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
        at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.execute(PhantomJSCommandExecutor.java:78)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
        ... 16 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:11594/status] to be available after 20027 ms
        at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
        at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
        ... 18 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
        at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
        at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
        ... 19 more
Caused by: java.util.concurrent.TimeoutException
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
        at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
        ... 20 more

在下面的方法中,我设置了驱动程序,但在返回语句期间出现异常:

private WebDriver createDriver(String phantomjsExeutableFilePath) {
        Suche.log(":::phantomjs path: " + phantomjsExeutableFilePath);
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setJavascriptEnabled(true);
        capabilities.setCapability(PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjsExeutableFilePath);
        return new PhantomJSDriver(capabilities); // Exception is thrown here
}

我已经从官方网站下载了 PhantomJS 库,并对它进行了chmod'ed。 这可能是 OrangePiOne 的错还是我错过了什么?

最佳答案

当我使用 phantomjs build for rasberry pi 而不是官方网站的版本时,它起作用了。 此问题已通过 https://github.com/fg2it/phantomjs-on-raspberry 中的 phantomjs-on-rasberrypi 解决。 .

关于java - UnreachableBrowserException - 在 OrangePiOne 上使用 PhantomJS 和 java 时 (Ubuntu 18.04.2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58492747/

相关文章:

java - JLabel 图像数组

Javascript Submit 未将 SUBMIT POST 发送到 php 文件

Java PhantomJSDriver 禁用控制台中的所有日志

python - 如何返回 selenium 浏览器(或如何导入返回 selenium 浏览器的 def)

java - 守护程序 java 进程 - 有这样的东西吗?

java - 用于将测试分离为单元和集成测试失败的 Maven Surefire 配置

java - 我需要在 JDA 中使用什么方法来检查消息是否包含图像?

java - Jacoco maven 插件使用 Exceptions-java.lang.IllegalStateException : class is already instrumented 阻塞控制台

JavaScript - 使用 Document Write 输出一行

java - 使用 Java 识别 RTF 表单元素