1

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因为它是不同的容器,所以不起作用)。有没有办法指定在无人机中运行管道的容器的主机名?或者以其他方式使服务可以访问主容器?

谢谢。

4

1 回答 1

4

您将需要下载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

希望这可以帮助!

于 2017-05-17T11:48:17.220 回答