I have been using Google Colab for my python projects. I want to learn & implement Selenium using Google Colab. I am trying to log in to Facebook as shown below. But, I am stuck with 'Permission error'. I have looked into various posts & tried to execute suggested solutions such as (Selenium on MAC, Message: 'chromedriver' executable may have wrong permissions) but did not help.
What I've tried.
- Referred https://sites.google.com/a/chromium.org/chromedriver/home article as suggested
- Used chmod 755 to allow executable permissions
- Referenced 'chromedriver.exe' in different folders within Colab environment and but no luck
The Code:
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
user_name = 'Username'
password = 'Password'
os.chmod('/content/chromedriver.exe', 755)
driver = webdriver.Chrome(executable_path='/content/')
driver.get("https://www.facebook.com")
element = driver.find_element_by_id("email")
element.send_keys(user_name)
element = driver.find_element_by_id("pass")
element.send_keys(password)
element.send_keys(Keys.RETURN)
driver.close()
Complete error:
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self)
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
4 frames
PermissionError: [Errno 13] Permission denied: '/content/'
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self)
86 raise WebDriverException(
87 "'%s' executable may have wrong permissions. %s" % (
---> 88 os.path.basename(self.path), self.start_error_message)
89 )
90 else:
WebDriverException: Message: '' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Snapshot of my Colab Environment
Can someone please help me fix this issue?
PS: The same code works using Jupyter Notebook, Eclipse IDE. But on the long run, I want to remove my dependence on Jupyter Notebooks & rely on Cloud based Notebook environment such as Google Colab which in theory should allow me to focus on code rather than troubleshooting libraries/compatibility/permission/etc issues.