1

I have a some script written on js in loadrunner. Yesterday I needed a function "web_submit_data". On C it's syntax looks like:

int web_submit_data(const char *StepName, const char *Action, <List of Attributes>, ITEMDATA, <List of data>, [EXTRARES, <List of Resource Attributes>,] LAST);

To set the "List of data" I need ENDITEM constant, but I can't find it in JS Vuser. I tried ENDITEM, web.ENDITEM, "ENDITEM", but its all does not works. So, now my call of this function looks like:

web.submit_data("bsi.dll_14",
  "Action=http://someaddr.org/a/b/c",
  new Array(
    "Method=POST",
    "EncType=multipart/form-data",
    "TargetFrame=",
    "RecContentType=text\html"
    "Referer=http://some.ref.link.org/"
    "Snapshot=t70.inf",
    "Mode=HTML"),
  new Array(
    new String("Name=exName1"), new String("Value=val1"),
    new String("Name=exName2"), new String("Value=val2")));

And I got no errors for this, however sended HTTP-package does not contain data, that i tried to send.
So, can anybody help me with this mad function? How I should use web.submit_data in Javascript vuser?
Thanks in advance.


P.S. Sorry for my bad English. I tried to write understandable.

Sergey Zalizko
  • 269
  • 2
  • 7
  • Hi, I think the "web" API is not officially supported for JSVuser. I tried all the permutations of "ENDITEM" I could think of and none of them helped. – Buzzy Mar 13 '13 at 16:37
  • Now I think same. Few days ago I found this link ( http://softwaretesttips.com/2011/04/19/incorporate-javascipt-into-a-loadrunner-web-script/ ), however it does not works too. – Sergey Zalizko Mar 14 '13 at 10:41

2 Answers2

0

I am not familiar with the JavaScript Vuser type, but I recognize the web.submit_data from coding JAVA into VUgen. If that is the same then I think your code should look like this:

web.submit_data("bsi.dll_14",
  "Action=http://someaddr.org/a/b/c",
  new String[]{                      // options[]
    "Method=POST",
    "EncType=multipart/form-data",
    "TargetFrame=",
    "RecContentType=text\html"
    "Referer=http://some.ref.link.org/"
    "Snapshot=t70.inf",
    "Mode=HTML"
  },
  new String[]{                     // data name/value pairs
    "Name=exName1", "Value=val1", web.ENDITEM,
    "Name=exName2", "Value=val2", web.ENDITEM,
    web.LAST
  });
Nathan
  • 341
  • 1
  • 4
  • Problem is that Javascript vuser does not contain web.ENDITEM. I got "not defined" error, when tried it. – Sergey Zalizko Mar 12 '13 at 19:26
  • Ok, then it's not JAVA you're coding in. Well, how about this, in the code you posted I see two typos (which I repeated in the code I posted), the RecContentType and Referer lines both need commas ',' at the end. Maybe you're just running into a simple code mistake? – Nathan Mar 12 '13 at 20:16
  • No, it's just misprint. In real code commas there. And it is not java, it is javascript. Looks similar, but have few differences. – Sergey Zalizko Mar 13 '13 at 07:58
  • Hmm, well, I guess then I'm curious as to why you're using the JavaScript Vuser type in the first place and not WEB/HTML (which includes JavaScript file request support already)? The WEB/HTML protocol will allow you to use web_submit_data(); – Nathan Mar 13 '13 at 17:10
  • After `var web = new ActiveXObject("LoadRunner.WebApi");` functions like **web.url**, **web.custom_request** works fine. – Sergey Zalizko Mar 14 '13 at 10:34
0

From the documentation:

Web Vuser Functions (WEB)
Web Vusers perform tests that communicate with the servers using the HTTP protocol. The                 Web protocol is generally used to test Internet sites.

The default language for the Web protocol is C. Recording sessions create tests in C.  

Java and Visual Basic syntax are supported for a sub-set of the Web functions. C++ can      be used when writing tests with external programming tools.

Web Vuser scripts are supported in three syntaxes:

Web Vuser Functions: C Language (WEB) 

Web Vuser Functions: Java Language (web.) 

Web Vuser Functions: VB (web.) 

So I guess JS is not supported.

Buzzy
  • 2,905
  • 3
  • 22
  • 31