简体   繁体   中英

Running Cucumber tests on headless Chrome

I am interested in running our acceptance tests with Cucumber. Is there any way to run them on Chrome's headless mode?

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

try those args ['--headless', '--disable-gpu']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM