【问题标题】:How to use chromium on embedded linux through Selenium如何通过 Selenium 在嵌入式 Linux 上使用 Chromium
【发布时间】:2019-01-25 08:04:47
【问题描述】:

环境:

  1. 在目标板上嵌入 linux 系统
  2. 安装了 chromium(不是 google chrome)
  3. 我可以通过 /usr/bin/chromium www.google.com 访问
  4. 安装了 python 模块 selenium.webdriver

问题描述:

  1. chromium 版本是“Chromium 71.0.3545.0 stable”,我的板上没有 google-chrome。 lrwxrwxrwx 1 root root 34 Nov 29 00:14 /usr/bin/chromium -> /usr/lib/chromium/chromium-wrapper

  2. 我下载了“ChromeDriver 2.45”->“chromedriver_linux64.zip”,上面写着 “支持 Chrome v70-72”,解压并把“chromedriver”放到/usr/bin

  3. 然后我按照以下步骤进行操作并得到这样的错误

    Python 2.7.15 (default, Nov 26 2018, 01:36:34)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from selenium.webdriver.chrome.options import Options
    >>> from selenium import webdriver
    >>> opts=Options()
    >>> opts.binary_location="/usr/bin/chromedriver"
    >>> driver=webdriver.Chrome(chrome_options=opts)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.7/site-p 
    packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
    File "/usr/lib/python2.7/site- 
    packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
    File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
    File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
    OSError: [Errno 8] Exec format error
    

【问题讨论】:

    标签: python selenium selenium-chromedriver embedded-linux chromium


    【解决方案1】:

    当您使用 目标板上的嵌入式 linux 系统Chromium 71.0 而不是 "ChromeDriver 2.45" -&gt;"chromedriver_linux64.zip" 时,您需要下载 chromedriver-v2.21-linux- armv7l 从这个link 并在您的程序中使用它,如下所示:

    from selenium.webdriver.chrome.options import Options
    from selenium import webdriver
    opts=Options()
    opts.binary_location='/path/to/chrome' #Chromium 71.0 executable binary
    driver = webdriver.Chrome(chrome_options=opts, executable_path='/path/to/chromedriver.exe')
    

    您可以在以下位置找到一些相关讨论:

    【讨论】:

    • 我按照你说的做了,但还是不行。它提示“消息:'chromedriver'可执行文件需要在PATH中”,似乎chromedriver与我的平台不匹配。
    • 我从 chromium.org 收到了这样的回复:今天(9 小时前)johnchen@chromium.org 的评论 4 项目成员标签:-Needs-Feedback 状态:WontFix(原为:未确认)我们不'不支持 arm CPU 上的 chromedriver,并且从未发布过在 arm 上运行的 chromedriver 版本。由于 chromedriver 是开源的,任何人都可以下载它的源代码并针对任何架构进行编译,但我们没有资源来支持这种用法。您可以尝试联系您获得 chromedriver 副本的网站。
    猜你喜欢
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 2011-04-13
    • 1970-01-01
    • 2020-10-30
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多