在无头Chrome上运行Cucumber测试

3

我希望使用Cucumber运行我们的验收测试。有没有办法在Chrome的无头模式下运行它们?


仅适用于最新版本的Linux或Mac上的Chrome。看看这个链接:https://intoli.com/blog/running-selenium-with-headless-chrome/。猜测一下 - 如果您能够使用Selenium连接,那么Cucumberjs应该可以以正常方式工作。 - Grasshopper
1个回答

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

尝试使用这些参数 ['--headless', '--disable-gpu']


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接