在arm cpu上,使用selenium,实现网页自动化测试

在arm上使用selenium,实现网页自动化测试,遇到了问题,现将解决方案和大家分享:
如何安装selenium

  1. 升级软件
    apt-get update
  2. 安装pip
    apt-get install python3-pip
  3. 安装selenium
    pip3 install selenium
  4. 安装chromedriver
    sudo apt-get install chromium-chromedriver
  5. 安装浏览器
    sudo apt install chromium-browser
  6. 查看安装路径
    dpkg -L chromium-chromedriver

以下是python代码,打开一个网站:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get(“http://www.baidu.com”)
遇到问题,错误提示如下:
*** selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

原因是未找到正确的程序,需要指定程序,完整代码如下:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
chrome_bin=r’/usr/bin/chromium-browser’
service = Service(executable_path=r"/usr/bin/chromedriver")

options = Options()
options.binary_location = chrome_bin

driver = webdriver.Chrome(service=service,options=options)
driver.get(“http://www.baidu.com”)

问题解决,开始你的自动化网页测试吧。