Quantcast
Channel: LoadRunner Practitioners Forum topics
Viewing all articles
Browse latest Browse all 3978

How to use asimple javascript-script to generate an argument to an input field?

$
0
0

This is supposed to be something really basic, but a search with google and on this forum did neither bring up any explanation nor an example. So this forum is - again - my last hope.

I would like to enter something into a textfield. If this text is hard-coded it is really simple:

 

LR1.png

 

But now I want to name the value to be something different each time. I can use javascript for that, where I replace the "PlainValue" with a "JS" as follows:

LR2.png

with the javascript expression as follows:

"Testtask_" + Math.floor((Math.random() * 1000000) + 1)

So far so good. But now I am trying to replace the single javascript statement with something more complex, like the following:

var currentdate = new Date();
var datetime = currentdate.getFullYear() + (currentdate.getMonth()+1) + currentdate.getDate() + "_"
+ currentdate.getHours()
+ currentdate.getMinutes()
+ currentdate.getSeconds();
return "Testtask-"+datetime;

But now when running this TruClient Script I get the following error:

** 4: Call Function SRG.action_search_task ** was aborted due to an error in the called function

Is the javascript in a wrong format? How to change the javascript-script so that the text-input field is populated with the desired date-output? Is there a way to get a more 'informative' error message?

I want a solution for the case when I have a multi-line javasvript-script! >>> Not just my script in a single line!! << I want a general solution for all the other multiline-cases I might encounter in future!!


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>