在无头Chrome上运行Cucumber测试

时间:2017-05-30 13:15:47

标签: javascript google-chrome testing cucumber

我对使用Cucumber进行验收测试感兴趣。有没有办法在Chrome的无头模式下运行它们?

1 个答案:

答案 0 :(得分:0)

import webdriver from 'selenium-webdriver'
import test from 'selenium-webdriver/testing'

test.describe('Test', () => {
  test.it('with headless chrome.', () => {
    const chromeCapabilities = webdriver.Capabilities.chrome();
    **chromeCapabilities.set('chromeOptions', {
      'args': ['--headless', '--disable-gpu']
    });**
    driver = new webdriver.Builder()
      .usingServer('http://localhost:4444/wd/hub')
      **.withCapabilities(chromeCapabilities)**
      .build();

    driver.get('http://www.google.com/');
    driver.quit();
  })
})

尝试这些args ['--headless','--disable-gpu']