Currently, if we initialize a driver in a feature and call another feature in it, once the called feature is executed it is quitting the parent feature's driver instance.
Feature: browser automation
Background:
* configure driver = { type: 'geckodriver', showDriverLog: true }
Scenario: try to login to github
Given driver 'https://google.com'
And input("input[name=q]", 'karate dsl')
When submit().click("input[name=btnI]")
Then match driver.url == 'https://github.com/intuit/karate'
* def callUsers = call read("users.feature")
* def bytes = driver.screenshot()
* karate.embed(bytes, 'image/png')
in the above example after users.feature it is observed that driver instance is quitting and usage of driver will give an error.
by changing
https://github.com/intuit/karate/blob/0d5cff99bc4eeda1a22ac73499ffee38ad29187d/karate-core/src/main/java/com/intuit/karate/Script.java#L274 to return callWithCache(text, arg, context, true);
and https://github.com/intuit/karate/blob/0d5cff99bc4eeda1a22ac73499ffee38ad29187d/karate-core/src/main/java/com/intuit/karate/Script.java#L276 to return call(text, arg, context, false);
seems to fix this, but want to understand the impact, can we go this approach?
I too have a similar issue. I would like a single instance of karate driver to be used across a scenario outline. As part of my test, I will have to post a message on to Kafka topic and observe some UI change. I will have to repeat this for different values of the message but the browser should not be refreshed or reloaded while I am posting these messages and checking the UI behavior.
@babusekaran looks like it was a one-line fix ! can you confirm ?
@venkiteelay for your use-case can you check if instead of using a Scenario Outline - you can use a call and loop over an array for data-driven testing, I am just trying to keep the framework simple
@ptrthomas Thanks! it is working fine 馃憤
released 0.9.5
@babusekaran Can you please share the code snippet to carry driver instance from one feature file to another?
@srkanpu By carrying driver from one feature file to another you mean calling another feature within a feature? if that's the case please refer to the code snippet and attachment at the top.