如何通过Selenium在嵌入式Linux上使用铬

时间:2019-01-25 08:04:48

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

环境:

  1. 目标板上嵌入了linux系统
  2. 已安装铬(不是Google chrome)
  3. 我可以使用/ usr / bin / chromium www.google.com
  4. 进行访问
  5. 已安装python模块selenium.webdriver

问题说明:

  1. 铬版本为“ Chromium 71.0.3545.0稳定”,并且我的板上没有google-chrome。 lrwxrwxrwx 1根根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
    

1 个答案:

答案 0 :(得分:0)

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

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

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