“语法错误:未终止引用的字符串”和“org.apache.commons.exec.ExecuteException:进程退出并显示错误:2(退出值:2)”

问题描述 投票:0回答:1

所以我想在我的覆盆子pi 3b上使用chromedriver,我得到了这个错误。

我已经安装了linux32位版本的chromedriver,它也找到了驱动程序。但在初始化驱动程序时它说:

/home/pi/Desktop/chromedriver: 1: /home/pi/Desktop/chromedriver: ELF�4���4: not found
/home/pi/Desktop/chromedriver: 2: /home/pi/Desktop/chromedriver: Syntax error: Unterminated quoted string

之后我得到一个超时和这个错误:

Sep 06, 2018 4:47:43 PM org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 2)
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'raspberrypi', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.14.34-v7+', java.version: '1.8.0_65'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
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 xxxxxxxx.initialize(xxxxxxxx.java:39)
at xxxxxxxx.main(xxxxxxxx.java:24)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out 
waiting for [http://localhost:18689/status] to be available after 20014 ms
at 
org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverServic 
e.java:187)
... 10 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:148)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)`

我的代码:

System.out.println("Starting Bot..");
    System.setProperty("webdriver.chrome.driver", "/home/pi/Desktop/chromedriver");
    System.out.println("yes");

    Map<String, String> mobileEmulation = new HashMap<>();
    mobileEmulation.put("deviceName", "Nexus 5");
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
    chromeOptions.addArguments("--headless");
    System.out.println("yes2");

    driver = new ChromeDriver(chromeOptions);
linux selenium selenium-webdriver selenium-chromedriver raspberry-pi3
1个回答
0
投票

此错误消息...

org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 2)

...暗示底层操作系统无法启动chromedriver进程。

您的主要问题是您使用的二进制文件版本之间的不兼容性如下:

  • 您的Selenium客户端版本是3.12.0。
  • 但你的JDK版本是1.8.0_65,这很古老。

因此JDK v8u65和Selenium Client v3.12.0之间存在明显的不匹配。

© www.soinside.com 2019 - 2024. All rights reserved.