【问题标题】:Bitbucket Pipeline fails attempting to run Nightwatch E2E tests with Chromedriver ErrorBitbucket Pipeline 无法尝试运行 Nightwatch E2E 测试并出现 Chromedriver 错误
【发布时间】:2019-09-06 05:21:21
【问题描述】:

我正在尝试在 bitbucket 管道中部署时使用 nightwatch 运行我的 E2E 测试。我在本地安装了 nightwatch,在我的 Windows 机器上安装了 chromedriver,一切正常。

当我在管道中运行 npm nightwatch 时收到此错误

An error occurred while trying to start ChromeDriver: cannot resolve path: "/opt/atlassian/pipelines/agent/build/node_modules/chromedriver/lib/chromedriver/chromedriver". Please check that the "webdriver.server_path" config property is set correctly.

这是它指定的路径的文件结构

文件结构

node_modules/
    chromedriver/
        lib/
            chromdriver/
                chromerdriver.exe
                chromedriver_win32.zip

很明显node_modules/chromedriver/lib/chromedriver/chromedriver 不存在。容器是Linux所以它不知道如何执行chromedriver.exe文件。

那么如何让 bitbucket 管道运行 chromedriver.exe?或者我如何让chromedriver 进入它正在寻找的路径。我很肯定以前有人遇到过这种情况。在这方面苦苦挣扎了一段时间,正在寻求帮助。谢谢。

bitbucket-pipelines.yml 文件

image: rastasheep/alpine-node-chromium
pipelines:
  custom:
    develop:
      - step:
          name: Serve and Test
          caches:
            - node
          script:
            - apt-get update && apt-get install -yq libnss3
            - if [ ! -d "node_modules/nightwatch" ]; then npm install; fi
            - npm start
            - npm run nightwatch

nightwatch.conf.js

const chrome = require('chromedriver')

module.exports = {
  'src_folders': [
    './nightwatch/tests/elements'
  ],
  'output_folder': './nightwatch/reports',
  'globals_path': './nightwatch/utils/globals/globals.js',
  'webdriver': {
    'start_process': true,
    'server_path': chrome.path,
    'log_path': './nightwatch/reports',
    'cli_args': [
      '--verbose'
    ],
    'port': 9515
  },
  'test_settings': {
    'default': {
      'launch_url': 'http://localhost:3100',
      'desiredCapabilities': {
        'browserName': 'chrome',
        'javascriptEnabled': true,
        'chromeOptions': {
          'args': [
            'no-sandbox',
            'headless'
          ]
        }
      },
      'screenshots': {
        'enabled': true,
        'on_failure': true,
        'on_error': true,
        'path': 'nightwatch/screenshots'
      }
    }
  }
}

【问题讨论】:

    标签: selenium-chromedriver nightwatch.js bitbucket-pipelines


    【解决方案1】:

    我能够通过删除rastasheep/alpine-node-chromium添加节点图像并在步骤中自己安装chrome来解决。

    image: node:10.15.0
    pipelines:
      default:
        - step:
        name: NewHomePageNav
        script:
          # First we are going to install dependencies that chrome and chromedriver will need
          - apt-get update && apt-get install -yq libnss3 unzip openjdk-8-jre-headless xvfb libxi6 libgconf-2-4
          # Install chrome browser as it does not exist with the node image
          - curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
          - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
          - apt-get -y update
          - apt-get -y install google-chrome-stable
          - npm install
          # Start and run your server. Using the & will allow bitbucket to move onto testing
          - npm start &
          - npm test
    

    【讨论】:

      猜你喜欢
      • 2017-12-18
      • 1970-01-01
      • 1970-01-01
      • 2022-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-15
      • 2023-03-14
      相关资源
      最近更新 更多