4

We are trying to co exist with another java project which uses Webdriver etc. As part of this we would like to re use the same .properties file that is being used by other project for our configuration etc. Could some one guide us on reading from .properties file in Karate DSL.

yek
  • 127
  • 1
  • 7
  • @vandit, You can take a look at below similar issue. https://stackoverflow.com/questions/76764921/reading-data-from-properties-file-in-karate-1-4-0-version-throws-error-org-g/76765153?noredirect=1#comment135339090_76765153 – ashwin Jul 26 '23 at 16:32

1 Answers1

5

There is nothing built in to Karate - but the solution for you is clear, write a simple Java utility to read a properties file - or since it is so simple, you should be able to do this even in JS, in the karate-config.js itself.

And also refer this: https://github.com/intuit/karate#calling-java

I haven't tested the below code, but you get the idea:

* def stream = read('classpath:myfile.properties')
* def props = new java.util.Properties()
* eval props.load(stream)
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Hi Peter, thanks for the response. I will try to implement it and see the possibility. On the other side it would be good if we can start a Slack community or rocket.chat community so that whole community gets involved in discussions. – yek Apr 04 '18 at 10:27
  • @peter eval props doesn't worked for me. test gets ignored. I am using 0.6.2 version of karate-apache – Vandit Jain Jun 23 '21 at 13:43
  • @VanditJain we no longer support old versions, sorry. if you are stuck on new versions, the only way you can solve problems like this is to follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Jun 23 '21 at 13:44