Reputation: 1
Soo i made a python script that uses selenium on my windows machine, now im trying to run it on my chromebook however i cant solve how to get the chromedriver for my chromebook.
Here is the python code:
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
warnings.filterwarnings("ignore", category=DeprecationWarning)
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.get("https://google.com")
it works perfect on my windows machine since i have chromedriver in the samme folder as my .py file.
but when trying to run python3 MyFile.PY
in Termial on my chromebook
i recive this:
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
Does any one here know how i can solve this at my chromebook, ive tried downloading chromedriver for linux and placing it in my Linux-files together whit MyFile.PY
Upvotes: 0
Views: 981
Reputation: 2051
I get the same. I can install chromedriver executable into /usr/local/bin/
then name it in the constructor of ChromeDriver() in python, and observe:
$ python3 test.py
Start tests
/home/paul/scm/MyProj/test.py:30: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
Traceback (most recent call last):
File "/home/paul/scm/MyProj/test.py", line 30, in <module>
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
File "/home/paul/.local/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/paul/.local/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/paul/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 272, in __init__
self.start_session(capabilities, browser_profile)
File "/home/paul/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 364, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/paul/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "/home/paul/.local/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
#0 0x5ad7cb440243 <unknown>
#1 0x5ad7cb2047a6 <unknown>
#2 0x5ad7cb22b94a <unknown>
#3 0x5ad7cb22949b <unknown>
#4 0x5ad7cb26b2a7 <unknown>
#5 0x5ad7cb26a8cf <unknown>
#6 0x5ad7cb261e53 <unknown>
#7 0x5ad7cb2349ea <unknown>
#8 0x5ad7cb235b2e <unknown>
#9 0x5ad7cb494d5e <unknown>
#10 0x5ad7cb498a80 <unknown>
#11 0x5ad7cb47a8b0 <unknown>
#12 0x5ad7cb499b63 <unknown>
#13 0x5ad7cb46bf75 <unknown>
#14 0x5ad7cb4bc998 <unknown>
#15 0x5ad7cb4bcb27 <unknown>
#16 0x5ad7cb4d7c23 <unknown>
#17 0x7d9d36ccfea7 start_thread
This would work on the Mac. There's something weird about Chrome & ChromeDriver on ChromeOS/Debian. There's an advice page that maybe deserves extra scrutiny - https://chromedriver.chromium.org/getting-started/chromeos and a published wrapper class - https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/common_lib/cros/chromedriver.py. This all feel quite far diverged from standard Selenium though
Upvotes: 0
Reputation: 102
With selenium you have to keep the chromedriver.exe in path. You can download the chromedriver from https://chromedriver.chromium.org/downloads and put the file in the same folder of the code or you can do:
driver = webdriver.Chrome(executable_path="path to the chromedriver", options=options)
Upvotes: 1