1

我想用我的小型 java 程序在网站上填写一个 html 表单,使用PhantomJS. 它在我的 Win 10 机器上进行了测试,并且运行良好。我也想在我的OrangePiOne (Armbian 5.85 and 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 的错还是我遗漏了什么?

4

1 回答 1

0

当我为 rasberry pi 使用 phantomjs 构建而不是来自官方网站的那个时,它起作用了。phantomjs-on-rasberrypihttps://github.com/fg2it/phantomjs-on-raspberry解决了这个问题。

于 2019-10-23T19:52:26.747 回答