How to submit a form that item value contains new line or space? (493 Views)
Reply
Visitor
John023
Posts: 2
Registered: ‎11-26-2013
Message 1 of 2 (493 Views)

How to submit a form that item value contains new line or space?

[ Edited ]

Here is the flow,

I request a URL, get a JSON return,  "requestId":"abc\\nabc"

Then I use this to catch it.

web_reg_save_param_regexp(
"ParamName=requestId",
"RegExp=\"requestId\":\"(.*?)\"",
SEARCH_FILTERS,
"Scope=Body",
LAST);

 In replay log, Notify: Saving Parameter "requestId = abc\nabc"

 

finally, submit the form

web_submit_data("statusPoll", 
	"Action=http://someurl/pages/statusPoll", 
	"Method=POST", 
	"RecContentType=application/json", 
        "Referer=http://someurl/pages/vehicle_status.jsp", 
	"Snapshot=t24.inf", 
	"Mode=HTML",
    "EncType=",
	ITEMDATA, 
	"Name=requestId", "Value={requestId}", ENDITEM, 
	LAST);

 In the detail log:

tor.c(93): t=132597ms: 168-byte request body for "http://someurl/pages/statusPoll" (RelFrameId=1, Internal ID=97)
tor.c(93): requestId=abc%5Cnabc

 

-------------------------- issue ------------------------

 

loadrunner did not url encode the \n newline to %0A as expected, actually loadrunner url encode \ to %5C ; n to n.

 

So, how can I got %0a in POST form?

 

and I try to use web_convert_param("requestId", "SourceEncoding=PLAIN", "TargetEncoding=URL", LAST ); It turned out some story.

 

Thank you!

 

 

Please use plain text.
Visitor
John023
Posts: 2
Registered: ‎11-26-2013
Message 2 of 2 (477 Views)

Re: How to submit a form that item value contains new line or space?

After some google, Maby I can use custom replace string function and web_custom_request to resove this issue.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation