2

I have captured a loadrunner script using Web-Http protocol. The website uses websocket internally. So I have the WebsocketCB and WebSocketBuffer files created. There is a WebSocketSend array where one of the values within the array needs to be modified before sending.

char WebSocketSend0[] = "Data: dynamicvalue";

I am able to save the dynamic values from another packet to a variable. But i am not able to substitute it in the above array. I used the following convention for a "test" variable

char WebSocketSend0[] = "Data: lr_eval_string("{test}")";

But it threw up lots of compilation errors. Is there anyway i can make the substitution , otherwise i have to write lots of code to modify the array.

Shaiju Janardhanan
  • 546
  • 1
  • 11
  • 21

1 Answers1

0

You have a function inside of string definition. I see no way this is a valid set of code for substitution.

Have you considered code which is C compliant?

char WebSocketSend0[] = lr_eval_string("Data: {test}");

Pick up a good C Primer. The Head First, 21 Days and Dummies series are all great books. I own the 21 Days and Dummies books myself.

James Pulley
  • 5,606
  • 1
  • 14
  • 14
  • I believe this is not valid either. Try `char* WebSocketSend0 = lr_eval_string("Data:{test}");` – tserg42 Jun 18 '16 at 17:49
  • Good point, mismatch on character array and pointer to char. Change the variable to a pointer and the lr_eval_string() evaluation picks up fine. – James Pulley Jun 18 '16 at 23:21
  • @JamesPulley I am aware that this is not possible in C. Just wanted to know if there are any features in loadrunner which would allow something like that. – Shaiju Janardhanan Jun 19 '16 at 10:46
  • "char *WebSocketSend0 = lr_eval_string("Data: {test}");" Works. Remember, this is just a string. It just happens to be defined in a different file. There is absolutely no reason why you cannot define and use this variable inside of your main action. Create a character array. Use sprintf() to seed it with the items you need. Then use it – James Pulley Jun 20 '16 at 11:20