1

I'm trying to set up Selenium testing for my node.js app with drone.io following this example: http://docs.drone.io/selenium-example/.

My .drone.yml looks like this:

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

services:    
  selenium:
    image: selenium/standalone-chrome

And I'm using selenium-webdriver like this:

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());
});

Now, the problem is that Selenium doesn't know URI the app running at (obviously, http://127.0.0.1:8080 doesn't work since it's the different container). Is there a way to specify the hostname of the container running the pipeline in drone? Or to make the main container accessible from services in some other way?

Thanks.

Dmitri Maltsev
  • 323
  • 1
  • 3
  • 10

1 Answers1

4

You will need to download drone/drone:latest to ensure you have the latest set of patches (or drone/drone:0.7 or higher for those reading this in the future).

Using the yaml in your example (copied below) selenium will be able to access your node application at http://test:8080 where test is the name of the pipeline step and network hostname.

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

Another tip is to make sure that yarn start is non-blocking and does not block the shell session. For more details see http://veithen.github.io/2014/11/16/sigterm-propagation.html.

Hope this helps!

Brad Rydzewski
  • 2,523
  • 14
  • 18