drone.io 0.6 的 Selenium 设置

Selenium setup with drone.io 0.6

我正在尝试使用 drone.io 为我的 node.js 应用程序设置 Selenium 测试,遵循以下示例:http://docs.drone.io/selenium-example/.

我的 .drone.yml 看起来像这样:

pipeline:
  test:
    image: node:latest
    commands:
      - yarn install
      - yarn build
      - yarn start
      - yarn test

services:    
  selenium:
    image: selenium/standalone-chrome

我正在使用 selenium-webdriver 这样的:

const driver = new webdriver.Builder()
  .withCapabilities(webdriver.Capabilities.chrome())
  .usingServer(`http://selenium:4444/wd/hub`)
  .build();

describe('Home page', () => {
  before(async () => await driver.get(`http://127.0.0.1:8080`));  // FIXME
  it('should render greeting', async () => {
    const src = await driver.getPageSource();
    chai.expect(src).contains('Hey there!');
  });
  after(async () => await driver.quit());
});

现在,问题是 Selenium 不知道应用 运行 的 URI(显然,http://127.0.0.1:8080 不起作用,因为它是不同的容器)。有没有办法在无人机中指定容器的主机名 运行 管道?或者以其他方式让服务可以访问主容器?

谢谢。

您将需要下载 drone/drone:latest 以确保您拥有最新的补丁集(或者 drone/drone:0.7 或更高版本供将来阅读本文的人使用)。

在您的示例中使用 yaml(复制在下方)selenium 将能够在 http://test:8080 访问您的节点应用程序,其中 test 是管道步骤的名称和网络主机名。

pipeline:
  test:
    image: node:latest
    commands:
      - yarn install
      - yarn build
      - yarn start
      - yarn test
services:    
  selenium:
    image: selenium/standalone-chrome

另一个提示是确保 yarn start 是非阻塞的并且不会阻塞 shell 会话。有关详细信息,请参阅 http://veithen.github.io/2014/11/16/sigterm-propagation.html

希望对您有所帮助!