Asdee gen
Asdee gen

Reputation: 33

How to automate the testing of razorpay sdk calls using karate framework?

I am currently doing the automation testing of micro service which uses razorpay sdk for all the payment related activities. And for writing automation test cases I am using karate framework. Now my service interact with razorpay with there sdk and not with any API. So I couldn't figure out any way on how we can automate these sdk calls, because it is not any API. The code that I am using to connect to razorpay is like this.

new Razorpay({
     key_id: <RazorPay Key>,
     key_secret: <RazorPay key secret>});

I cannot mock the API like pathSelect(\orders) in karate as these API calls razorpay sdk is making internally in there system. I am new to karate framework so just wanted to know if there is anywat to automate these sdk calls to razorpay as we are not using any API to interact with it.

Upvotes: 1

Views: 150

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

The recommended option is to reverse-engineer the HTTP calls that the SDK is doing. At the end of the day that SDK JS will be doing nothing but a simple GET or POST call. Just look at the "network" tab of the browser or use something like Fiddler, and you will be able to very quickly figure out what the calls are, what URL and payload, etc.

Once you have the HTTP calls, you know what to do in Karate.

Otherwise Karate cannot call JavaScript directly. The other option I can think of is to open a Chrome browser using Karate UI, load the JS into it and then use the script() command or even perform the steps of entering payment info and clicking buttons via the UI.

If you are able to use the SDK via the CLI, for e.g. if you can write some Node JS code and invoke it, then Karate has helpers: https://stackoverflow.com/a/62911366/143475

Upvotes: 1

Related Questions