Wesley Droll
Wesley Droll

Reputation: 1

Selenium with Chromium driver on Raspberry Pi

I am trying to run a Selenium script from a JAR file on a Raspberry Pi Zero 2, and get this error:

Exception in thread "main" org.openqa.selenium.remote.NoSuchDriverException: Unable to obtain: Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless=new], binary: /usr/bin/chromedriver, extensions: []}}, error Command failed with code: 2, executed: [--browser, chrome, --language-binding, java, --output, json, --browser-path, /usr/bin/chromedriver]
/tmp/selenium-manager12749831998940039089/manager/0.4.18/selenium-manager: 1: Syntax error: "(" unexpected
at org.openqa.selenium.remote.service.DriverFinder.getPath(DriverFinder.java:48)
at org.openqa.selenium.remote.service.DriverFinder.getPath(DriverFinder.java:33)
at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:99)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:89)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:84)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:73)
at chess.Main.main(Main.java:13)
Caused by: org.openqa.selenium.WebDriverException: Command failed with code: 2, executed: [--browser, chrome, --language-binding, java, --output, json, --browser-path, /usr/bin/chromedriver]
/tmp/selenium-manager12749831998940039089/manager/0.4.18/selenium-manager: 1: Syntax error: "(" unexpected
at org.openqa.selenium.manager.SeleniumManager.runCommand(SeleniumManager.java:159)
at org.openqa.selenium.manager.SeleniumManager.getDriverPath(SeleniumManager.java:303)
at org.openqa.selenium.remote.service.DriverFinder.getPath(DriverFinder.java:45)
... 6 more
Caused by: org.openqa.selenium.json.JsonException: Unable to parse: /tmp/selenium-manager12749831998940039089/manager/0.4.18/selenium-manager: 1: Syntax error: "(" unexpected
at org.openqa.selenium.json.Json.toType(Json.java:169)
at org.openqa.selenium.json.Json.toType(Json.java:152)
at org.openqa.selenium.manager.SeleniumManager.runCommand(SeleniumManager.java:144)
... 8 more
Caused by: org.openqa.selenium.json.JsonException: Unable to determine type from: /. Last 1 characters read: /, next 106 characters to read: tmp/selenium-manager12749831998940039089/manager/0.4.18/selenium-manager: 1: Syntax error: "(" unexpected
Build info: version: '4.18.1', revision: 'b1d3319b48'
System info: os.name: 'Linux', os.arch: 'arm', os.version: '6.1.21-v7+', java.version: '11.0.22'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.json.JsonInput.peek(JsonInput.java:166)
at org.openqa.selenium.json.JsonTypeCoercer.lambda$buildCoercer$6(JsonTypeCoercer.java:167)
at org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java:146)
at org.openqa.selenium.json.Json.toType(Json.java:206)
at org.openqa.selenium.json.Json.toType(Json.java:167)

This is the (extremely simple) script:

package chess;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class Main {

public static void main(String args[]) {
    ChromeOptions c = new ChromeOptions();
    c.setBinary("/usr/bin/chromedriver");
    c.addArguments("--headless=new");
    WebDriver chess = new ChromeDriver(c);
    chess.get("https://chess.com");
    System.out.print(chess.getTitle());
}

}

I run the JAR using this command: java -cp ch9.jar chess.Main, and expect it to simply print the title of the chess.com website. (I plan to do much more with this later, i just want to make sure I can get the driver working before I commit to developing more.)

i have installed the chromium driver for raspberry pi : sudo apt install chromium-chromedriver

and i have the latest openjdk version

It should be noted that i am using maven in eclipse on my laptop to develop this, and i package it into a 'fat' jar with all of the dependencies, so i have not installed selenium on the pi itself. The jar executes with no problems on my windows laptop (when i change the setBinary file path), but the path i put to run on the pi is the output of whereis chromedriver.

Furthermore, when i type in 'chromedriver' in the usr/bin directory it starts up chromedriver with no issues, and i verified the browser and driver are the same version. All the other selenium on raspberry pi threads i visited were in python and using pip, and they usually contain errors therein.

Upvotes: 0

Views: 241

Answers (0)

Related Questions