Chromebook上的Selenium CANT CONT CHOMEDRIVER

发布于 2025-02-09 02:24:46 字数 1335 浏览 1 评论 0原文

Soo,我制作了一个Python脚本,该脚本在Windows机器上使用Selenium,现在我试图在Chromebook上运行它,但是我无法解决如何将Chromedriver用于Chromebook。

这是Python代码:

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")

它在Windows Machine上的功能非常完美,因为我将Chromedriver作为.py文件中的Chromedriver。

但是,在我的chromebook上的术语中尝试运行python3 myfile.py 我恢复了这个问题:

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

这里的任何人都知道如何在Chromebook上解决此问题,Ive尝试下载Chromedriver以for Linux并将其放在我的Linux-Files中,将其放在我的Linux-Files中whit myfile.py.py

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羞稚 2025-02-16 02:24:46

使用硒,您必须将Chromedriver.exe保持在路径中。
您可以从

driver = webdriver.Chrome(executable_path="path to the chromedriver", options=options)

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)
眼中杀气 2025-02-16 02:24:46

我也一样。我可以将Chromedriver可执行文件安装到/usr/usr/local/bin/中,然后在Python的Chromedriver()构造函数中命名,并观察:

$ 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

这将在Mac上使用。 Chrome&amp; Chromedriver在Chromeos/Debian上。 There's an advice page that maybe deserves extra scrutiny - https://chromedriver.chromium.org/getting- start/chromeos 和出版的包装班 - https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/client/common_lib/cros/cros/chromedriver.py 。这一切都与标准硒相差很大

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文