User avatar
Spajk
Posts: 11
Joined: Tue Nov 29, 2016 5:56 pm
Contact: Website

Running headless chromium and chromedriver

Wed Sep 27, 2017 6:20 pm

Hi, I am having problems getting this to work. More specifically, I can't get chromedriver to work.

Do I have to compile everything from scratch?

chgruem
Posts: 1
Joined: Mon Oct 02, 2017 6:28 pm

Re: Running headless chromium and chromedriver

Wed Oct 04, 2017 7:32 pm

Hi,

Since the chromedriver is not in the official raspbian repository, you have to get it from here: https://packages.debian.org/stretch/arm ... r/download
Unpack the file "chromedriver" from the archive to /usr/local/bin

Then follow these steps:
sudo chmod +x /usr/local/bin/chromedriver
sudo apt-get install libminizip1
sudo apt-get install libwebpmux2

If you are on Raspbian Stretch Lite (no desktop environment) you also have to install this package:
sudo apt-get install libgtk-3-0

In your code add these two arguments, when you start the driver:
-headless
-disable-gpu

See also my code below, section //Headless?:

Code: Select all

using System;
using OpenQA.Selenium.Chrome;

namespace WiControlForConnectBox.Selenium
{
	public class LibChrome : LibConnectBox
	{
		public LibChrome (bool HeadlessMode)
		{
			//Optionen einstellen
			var options = new ChromeOptions();
			options.AddArgument(@"disable-translate");
			options.AddArgument(@"disable-infobars");

			//Headless?
			if (HeadlessMode)
			{
				options.AddArgument(@"headless");
				options.AddArgument(@"disable-gpu");
				options.AddArgument(@"window-size=1024,768");
			}
					
			//Treiber starten (chromedriver muss in /usr/local/bin kopiert werden)
			var driver = new ChromeDriver(options);
		
			//Timeout festlegen
			driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);

			//Treiber eintragen
			base.Driver = driver;
		}
	}
}
Best regards,
chgruem

multifractal
Posts: 1
Joined: Tue Feb 20, 2018 11:27 pm

Re: Running headless chromium and chromedriver

Tue Feb 20, 2018 11:28 pm

@chgruem, Thank you very much for this answer.
I've been searching for a way to set up selenium in my Raspberry for hours.
This was amazing, thank you

Mr-Programs
Posts: 1
Joined: Sun Oct 14, 2018 11:27 pm

Re: Running headless chromium and chromedriver

Sun Oct 14, 2018 11:51 pm

so one thing is that your code seems to be... C#?
using with python Ive been trying to achieve headless scrapping on raspberry pi 3 b+

Ive been following this steps which is unfortunately a closed thread

https://www.reddit.com/r/selenium/comme ... driver_on/

somebody told me i need to put chromium and chromedriver on the same folder??? im actually confused in many aspects


also...

might sound lame but since i did a

sudo mv /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver

does this mean

driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver')

becomes

driver = webdriver.Chrome('chromedriver')
? OR
driver = webdriver.Chrome()

Return to “Advanced users”