CentOS7.6 上执行 UI 自动化测试用例

发布于 更新于
本文目录
  1. 一、CentOS7.6 安装 Chrome(谷歌)浏览器
  2. 二、安装对应版本号的 chromedriver.exe
  3. 三、Python 安装所需要依赖的包
  4. 四、执行 UI 自动化测试用例

技术文章自动化测试

打开终端,使用 root 用户登录

一、CentOS7.6 安装 Chrome(谷歌)浏览器

  • 打开终端,使用 root 用户登录

  • 配置 yum 下载源

    cd /etc/yum.repos.d/
    vi google-chrome.repo
    [google-chrome]
    name=google-chrome
    baseurl=https://dl.google.com/linux/chrome/rpm/stable/x86_64
    enabled=1
    gpgcheck=1
    gpgkey=https://dl.google.com/linux/linux_signing_key.pub
  • 安装

    cd /opt
    yum -y install google-chrome-stable --nogpgcheck
  • 查看安装的谷歌浏览器版本号

    google-chrome --version
    image.png

二、安装对应版本号的 chromedriver.exe

cd /opt/
wget https://registry.npmmirror.com/-/binary/chromedriver/103.0.5060.53/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
mv chromedriver /usr/bin/
chmod +x /usr/bin/chromedriver

三、Python 安装所需要依赖的包

pip3 install pytest
pip3 install selenium

四、执行 UI 自动化测试用例

注意:因为 chromedriver 默认弹窗,需要设置不弹窗!!!

image.png
  • 执行测试

    python3 -m pytest test_login.py
    image.png

来源:testingpai

继续阅读