如何在GitLab中运行python+selenium自动测试?

2024-04-29 09:15:55 发布

您现在位置:Python中文网/ 问答频道 /正文

是否可以在GitLab中运行在Python+Selenium上编写的自动化测试? 我在网上找不到信息。我知道有Jenkins,但我想在GitLab中运行自动测试,然后在Allure中创建一个报告(如果可能的话)


Tags: 信息报告seleniumgitlab自动测试jenkinsallure
1条回答
网友
1楼 · 发布于 2024-04-29 09:15:55

Is it possible to run automation tests written on Python + Selenium in GitLab?

有几种方式/类型的gitlab-runner executorsdockerdocker-composeshell可以实现这一点

带有dockergitlab runner executor的示例:

.gitlab-ci.yml

image: python:3.7.9-alpine
stages:
  - test

e2e:chrome:
  services:
    - selenium/standalone-chrome  # it's need to be configured with Remote webdriver in your tests to look at http://selenium__standalone-chrome:4444/wd/hub
  before_script:
    - pip3 install -r requirements.txt  # you can optimize this step by building your own image with pre-installled requirements and using it instead of current python:3.7.9-alpine image 
  script:
    - pytest /path/to/your/tests 
  

这是一个可以使用gitlab-ci执行python上的selenium测试的可行示例

标签1.0.0https://github.com/aleksandr-kotlyar/python-gitlabci-selenium/releases/tag/1.0.0给出了完整的简单示例

标签2.0.0https://github.com/aleksandr-kotlyar/python-gitlabci-selenium/releases/tag/2.0.0提供了更复杂的多浏览器示例

标记2.1.0提供的本地docker示例 https://github.com/aleksandr-kotlyar/python-gitlabci-selenium/releases/tag/2.1.0

免责声明:我为新手开发了PythonGitlab ci和另一个PythonCI模板,因此我将非常感谢我的项目https://github.com/aleksandr-kotlyar/python-gitlabci-selenium/中的反馈和请求

相关问题 更多 >