【问题标题】:How I can run selenium?我如何运行硒?
【发布时间】:2023-01-13 00:27:00
【问题描述】:

我有舞台,在那里我为我们的应用程序进行测试

test-dev:
  stage: test
  image: selenium/standalone-chrome
  image: node:14.15.0-stretch
  script:
    - npm i
    - npm run prod
    - /opt/bin/start-selenium-standalone.sh
    - npx mocha tests/js/screenshots-* --timeout 50000
    - npx playwright test tests/js/pw_*
    - php artisan test
  artifacts:
    when: always
    name: $CI_COMMIT_SHA
    untracked: true
    paths:
      - tests/js/screenshots/
      - tests/js/screens/
      - tests/js/report/
  cache:
    untracked: true
    when: always
    paths:
      - tests/js/screenshots/
      - tests/js/screens/
      - tests/js/report/
      - storage/
      - vendor/ #composer packages
      - node_modules
      - public

但是系统找不到start-selenium-standalone.sh,在原来的docker镜像中是在/opt/bin 我怎样才能启动它?

【问题讨论】:

  • 您只能为一个作业指定一个image。在这种情况下,它会拾取不包含硒的 node:14.15.0-stretch。

标签: docker image gitlab-ci gitlab-ci-runner


【解决方案1】:

我编写了下一个 Dockerfile 并使用它们:

文件

FROM ubuntu:latest
FROM node:14.15.0-stretch AS node
RUN npm i libnpx
FROM selenium/standalone-chrome:latest as sel

USER root
#selenium copy
#COPY --from=sel /opt/bin/start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
#COPY --from=sel /etc/supervisor/conf.d/ /etc/supervisor/conf.d/
#COPY --from=sel /opt/bin/generate_config /opt/bin/generate_config
#COPY --from=sel /opt/selenium/config.toml /opt/selenium/config.toml
#COPY --from=sel /opt/selenium/browser_name /opt/selenium/browser_name
#ENV SE_RELAX_CHECKS true
EXPOSE 4444
EXPOSE 7900

#Nodejs
#COPY --from=node / /
COPY --from=node /usr/local/lib/ /usr/local/lib/
COPY --from=node /usr/local/bin/ /usr/local/bin/
COPY --from=node /usr/local/bin/ /usr/local/bin/
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm


LABEL miekrif uzvar-selenium

CMD ["bash"]

在以下工作中:

test-dev:
  stage: test
  image: miekrif/uzavr-selenium:latest
  script:
    - nohup /opt/bin/entry_point.sh &
    - npx mocha tests/js/screenshots-* --timeout 50000
    - npx playwright test tests/js/pw_*
    - php artisan test
  artifacts:
    when: always
    name: $CI_COMMIT_SHA
    untracked: true
    paths:
      - tests/js/screenshots/
      - tests/js/screens/
      - tests/js/report/
  cache:
    untracked: true
    when: always
    paths:
      - tests/js/screenshots/
      - tests/js/screens/
      - tests/js/report/
      - storage/
      - vendor/ #composer packages
      - node_modules
      - public
  tags:
    - test_new_runner
  only:
    - ned_runner #Затычка бранча чтобы ранер не запускался
#    - develop

【讨论】:

    猜你喜欢
    • 2015-06-15
    • 1970-01-01
    • 2012-02-11
    • 2020-02-09
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多