After reading https://intuit.github.io/karate/#json-function-data-source
Given the following test script chrome operates in headless mode as would be expected but if you uncomment out the generator function and use as in the subsequent case.
Feature:
Background:
* configure driver = { type: 'chrome', headless: true, showDriverLog: false }
#* def generator =
#"""
# function(i) {
# return [
# { site: 'https://www.apple.com' },
# { site: 'https://www.craigslist.org' },
# { site: 'https://www.google.com' },
# null
# ][i]
# }
#"""
* def d = 'c'
Scenario Outline:
#* call read('test2.feature')
* driver site
* print c
* delay(4000)
Examples:
| site |
| https://www.google.com |
| https://www.google.com |
Here the headless mode is ignore and it seems like configure driver = {...} has no effect. In both the above and below case 'c' prints as expected for the * print d statement.
Feature:
Background:
* configure driver = { type: 'chrome', headless: true, showDriverLog: false }
* def generator =
"""
function(i) {
return [
{ site: 'https://www.apple.com' },
{ site: 'https://www.craigslist.org' },
{ site: 'https://www.google.com' },
null
][i]
}
"""
* def d = 'c'
Scenario Outline:
#* call read('test2.feature')
* driver site
* print c
* delay(4000)
Examples:
| generator |
I would like to understand what is happening. My impression is that the context is being overwritten by the generator. If that was the case why would 'configure driver' not work but 'def d' does?