0

My Application Under Test is a WebSocket based application.

I have to automate the functional scenarios but don't know how to do it or what tools to use.

I have googled from my side and have found that postman currently does not have support for websocket.

I also come across somecode examples but it is not working as the examples were just showing how to send a text to or recieve text from websocket.

And my application requires different type of parameters and value and the examples which I came across shows just to send text and receive text from websocket.

So if you know how to do this, then please help me.

  • github.com/websockets/ws – PDHide Apr 10 at 11:14
  • Please update your question with code samples that you have tried and the error you received. Please also add the format that the socket expects to receive and the format responses will take. – Kate Paulk Apr 10 at 13:03
  • Can you please elaborate whatt do you mean functional automation? Seems like you want to test it like API as you mentioned postman. – Amol Apr 10 at 16:05
  • @KatePaulk Thanks but now I have solved it using Karate tool, and posted the solution which worked for me. – SRM21 Apr 13 at 7:29
  • @Amol Yes my requirement are similar to what you are saying. I want to provide websocket different inputs and I am expecting the expected outputs and need to have validation for the same. I have right now started with Karate tool and what I have started it have posted it in answer. – SRM21 Apr 13 at 7:31
1

I was able to send the basic input as per my requirement using Karate tool.

Below is the code I modified as per my requirement from the example provided in the documentation, I have used Karate archtype to create this maven project and updated the karate-config.js as per the latest documentation:

  1. Feature File Code

@ignore Feature: wspoctest

Scenario: send first webscoket request Given def demoBaseUrl = 'wss://myURL' And def socket = karate.webSocket(demoBaseUrl, null) And def txt = '{"attr1":"value1","attr2":"value2"}'
When socket.send(txt) And def result = socket.listen(5000) Then print(result)

  1. Java Code
package wspoc;

import org.junit.BeforeClass;
import org.junit.runner.RunWith;

import com.intuit.karate.KarateOptions;
import com.intuit.karate.junit4.Karate;

@RunWith(Karate.class)

@KarateOptions(features = "classpath:wspoc/wspoc.feature")
public class WSPOCRunner
{

  @BeforeClass
  public static void beforeClass()
  { // skip 'callSingle' in karate-config.js 
      System.setProperty("karate.env", "mock");
  }
}

Now since my basic scenario is working fine, I am planning to modify and update this into the solution which I want.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.