首页 > 解决方案 > 如何在 gitlab-ci 上启动一个 selenoid?

问题描述

我正在尝试在 gitlab-ci 上运行测试,但我不知道启动 selenoid 的命令。在本地,这个命令看起来像./ Cm selenoid start但是在从服务启动 selenoid 的情况下如何指定,我不知道。这是我的.gitlab-ci.yml

stages:
  - testing

ya_test:
  stage: testing
  tags:
    - docker
  services:
    - selenoid/chrome
  image: python:3.9-alpine
  before_script:
    - pip3 install -r requirements.txt
    - selenoid/chrome start         #???????
  script:
    - pytest -s
  allow_failure: true

以及在测试夹具中指定什么地址?本地主机:4444?谢谢您的帮助!

标签: user-interfacegitlabwebdrivergitlab-ci

解决方案


要使用 Chrome 启动 Selenoid,请尝试使用此 yml。使用 webdriver.Remote(command_executor="http://selenoid__chrome:4444", options=chrome_options, desired_capabilities=DesiredCapabilities.CHROME) 连接 Chrome 并在选项中添加无沙箱。

image: python:3.8

stages:
  - test

test:
  stage: test

  services:
    - name: aerokube/selenoid
    - name: selenoid/chrome:89.0

  before_script:
    - echo "Install environment"
    - apt-get update -q -y
    - pip3 install -r requirements.txt

  script:
    - echo "Run all tests"
    - py.test -s -v  --junitxml=report.xml test.py

  # if you want detailed report at GitLab add artifacts 
  artifacts:
    when: always
    reports:
      junit: report.xml

推荐阅读