1

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?

C. Kena
  • 19
  • 6

1 Answers1

0

This very well could be a bug. This looks a little convoluted to me and can very well be a limitation of the way configure is implemented.

Please follow this process so that the project developers can investigate further and fix if required: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

UI testing is VERY hard and we'd like some more community contributions. If you are trying to do parallel testing, there are other recommended ways to manage this.

Refer this answer for example: https://stackoverflow.com/a/60387907/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 1
    This was in line with what I had come believe after looking at how Scenario Outline and Scenario is implemented. I rationalized Scenario Outline - is just configuring the data setting up for parallel running and should do the configure in the Scenario if I want to run it this way. I briefly looked at the stack overflow link you provided and looks like worthwhile read so much appreciation. Thank you, going to read it now! – C. Kena Mar 27 '21 at 06:51