2

I am using karate framework for UI Automation. Does Karate framework supports headless browser testing.

P K
  • 41
  • 3

2 Answers2

2

Yes if you use the driver type chrome or the Docker container: https://github.com/intuit/karate/tree/master/karate-core#dockertarget

* configure driver = { type: 'chrome', headless: true }
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
2

We can also use chromedriver or geckodriver to get headless working for chrome and firefox. But bear in mind, these need to be consistent with the browser version. Not advisable for CI/CD. But works if we need to test locally. Here was my config in karate-config.js(to use globally):

Chromedriver:

karate.configure('driver', {type: 'chromedriver', executable: '#(driverpath)' , webDriverSession: { desiredCapabilities: { browserName: 'chrome' , "goog:chromeOptions": { headless: true } } } } ); 

Firefox(geckodriver)

karate.configure('driver', {type: 'geckodriver', executable: '#(driverpath)', showDriverLog: true,  webDriverSession: { "capabilities": { "alwaysMatch": { "moz:firefoxOptions": { args: ["-headless"] } } } } } );
Mihir
  • 491
  • 5
  • 21