Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading data from .properties file in Karate DSL

Tags:

karate

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.

like image 595
yek Avatar asked Oct 27 '25 03:10

yek


1 Answers

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)

EDIT: In newer versions of Karate you need to do this instead: https://stackoverflow.com/a/76765153/143475

like image 151
Peter Thomas Avatar answered Oct 29 '25 22:10

Peter Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!