Search code examples
soapautomationautomated-testsbddkarate

Is it possible to have multiple URLs under the Background section - Karate API?


As I need to have single feature file with multiple scenarios, and each scenario will have different SOAP Request that belongs to various WSDL URL.

So will Karate API allow me to put multiple URLs for each scenario?

If Yes, how can I write the script for that? if No, please suggest me the alternative option.

Thanks.


Solution

  • Have an separate java utility to load all the URLs into an Map and have an another method to return URL when scenario name is given as input(getting value for the key in map). example code in feature file:

    Scenario:scenario1
    And def URL = Java.type( 'URLReader.java' ) 
    And def FirstScenrioURL = URL.getMapValue('scenario1')
    Given url FirstScenrioURL 
    

    Try this one..