Trying to get selenium working

Hi all,

Trying to get selenium working and coming across the issue below:
WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://chromedriver.chromium.org/home

Have tried a few things with different errors, but the one I’m getting is based on below:

!export PATH="/data/workspace_files:$PATH"
!export PATH="/data/notebook_files:$PATH"

import os
import sys

driver_path = '/data/notebook_files/chromedriver'
sys.path.insert(0, driver_path)

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

options = Options()
options.binary_location = driver_path
options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
service = Service(executable_path=driver_path)
driver = webdriver.Chrome(service=service,options=options)

Has anyone managed to get around this in DataLore?

Hi,

WebDriverException: Message: ‘chromedriver’ executable may have wrong permissions. Please see ChromeDriver - WebDriver for Chrome

You need to set correct permissions for the chromedriver binary. F.e. it could be done with the following code:

os.chmod(driver_path, 0o755)
1 Like

Thanks Igor,

That’s got me to the next step which is awesome, but then now I’m encountering the below:

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Stacktrace: #0 0x561990bf7aa9 <unknown>

Code below:
!pip install --upgrade webdriver-manager
!pip install --upgrade selenium

# !cd /data/notebook_files/
!sudo apt update
!sudo apt install -y chromium-browser
# !sudo apt install -y chromium-chromedriver
!export PATH="/data/workspace_files:$PATH"
!export PATH="/data/notebook_files:$PATH"

import os

import sys

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
driver_path = r'/data/notebook_files/chromedriver'
sys.path.insert(0, driver_path)
os.chmod(driver_path, 0o755)

options = Options()

# options.binary_location = driver_path

options.binary_location = r'/usr/bin/chromium-browser'
options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
service = Service(executable_path=driver_path)
driver = webdriver.Chrome(service=service,options=options)

I’ve made sure to use the suitable version of chromedriver (85.0.4183.83, as you can see I tried to get via terminal but didn’t have much luck there so reverted back to the manually downloaded copy) and have tried a few suggestions from what I could see on the internet but have not had much luck.

Any help is appreciated.