I'm using the google AIY voice project for the Raspberry Pi that came with magpi issue 57. I have had a lot of success despite being new to pi's which is nice.

I'm struggling to open chromium-browser so that automatically goes to a URL I give it. After searching on the internet I started using selenium and managed to get the browser to open but it wont go to any URL I pass. The current code in my Python file is:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

station = 'http://icy-e-bz-04-cr.sharp-stream.com/planetrock.mp3'

driver = webdriver.Chrome(executable_path="/usr/lib/chromium-browser/chromium-browser")

This half works and opens chromium but doesn't then go to the 'station' I provided. Any ideas on how to fix this?

  • Having looked at some example code most people have the URL directly located in driver.get (). E.g: driver.get("http://icy-e-bz-04-cr.sharp-stream.com/planetrock.mp3"). That might be worth a try.
    – Darth Vader
    Commented May 27, 2017 at 10:16
  • Abandoned post by Unregistered user.
    – Milliways
    Commented Apr 22 at 13:34

4 Answers 4


You can also try shell/command line syntax via python

chromium-browser <web_url> <web_url> <web_url>

works on raspbian


Follow this code to get your code worked.

import webbrowser, os, sys

url = ""

chrome_path = '/usr/lib/chromium-browser/chromium-browser'
  • Is it possible to close the window also form python? Commented Apr 2, 2021 at 11:36

I had similar problems on a Raspberry B+ with Stretch. I could solve the issues by

  1. creating a symlink named 'google-chrome' pointing to '/usr/lib/chromium-browser/chromium-browser'
  2. replacing "driver." in the python-code with "browser." as example below:


#!/usr/bin/env python3
import time
from selenium import webdriver
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import B
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
usernameStr = 'abcdef'
passwordStr = 'uvwzyx'
findStr1 = 'Welcome abcdef!'
findStr2 = 'Password'

driver = '/usr/lib/chromium-browser/chromedriver'
chrome_options = Options()
chrome_options.binary_location = "/usr/lib/chromium-browser/chromium-browser"
browser = webdriver.Chrome(chrome_options=chrome_options)

delay = 5
for element in browser.find_elements_by_xpath("//*[contains(text(), findStr1)]"):
    et = element.text
    print (et)
    if et == findStr1:
        print ("already connected")
    elif et.find(findStr2):
        print ("not connected yet")

In case I would replace 'browser' with 'driver' I would get tons of errors. I was close to give up because elsewhere I found statements, that selenium dos not support raspberry resp chromium-browser anymore.
I am using a script to auto-connect after boot to the wifi network in my apartment. The lines above are the first commands.
In case of 'connection' (that happens sometimes) the script stops.
In case of 'no connection' the login-form is being filled and submitted by further code, which is not displayed here.
Not 100% your question but you might give this a try.


  • 1
    Doesn't work because there is an indention error in the for loop.
    – Ingo
    Commented Dec 20, 2018 at 9:57
  • This problem might be due to the formatting options in mini-Markdown formatting options of this webpage. (I have to use 4 spaces to display the code) Commented Dec 21, 2018 at 4:39
  • 1
    Use a code editor like i.E "IDLE" to debug this code or a text-editor and replace blanks in indentation. Indentation needs to be done with tabs instead of blanks. Mixing tabs and spaces causes errors Commented Dec 21, 2018 at 4:55
  • I have formated the code. Please check it. For what is delay = 5? It isn't used.
    – Ingo
    Commented Dec 21, 2018 at 11:42
  • use Python3 IDLE! load the code with 'file open' and click on 'run Check Module'. In case of no errors run the code! Commented Dec 21, 2018 at 12:40

for /usr/bin/xdg-open: 811: : Permission denied

import os

os.system("chromium https://mesebilisim.com")


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.