javascript 如何参数化 ajax TruClient 脚本中的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12152089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:27:26  来源:igfitidea点击:

How to Parameterize the values in ajax TruClient scripts

javascriptajaxloadrunnertruclient

提问by dongjingru

This is the scenario - There is a search criterion giving me 100 search results (100 Links). I want the virtual users to click on any of those links ramdomly. Can you please help me how manage this situation?

这是场景 - 有一个搜索条件给了我 100 个搜索结果(100 个链接)。我希望虚拟用户随意点击这些链接中的任何一个。你能帮我如何处理这种情况吗?

回答by James Pulley

Your path is through correlating the links into an array, picking a random offset into the array and then a web_url to head to the link in question....

您的路径是通过将链接关联到一个数组中,在数组中选择一个随机偏移量,然后使用 web_url 前往有问题的链接......

回答by K.Sandell

Have a look at the help for the functions

看看功能的帮助

web_reg_save_param()
web_reg_save_param_ex()

and especially the "Ord=All"/"Ordinal=All" parts in the help.

尤其是帮助中的“Ord=All”/“Ordinal=All”部分。

Then when you have captured the relevant data into an array you can use

然后,当您将相关数据捕获到数组中时,您可以使用

lr_paramarr_random("TheArrayName");

to get a random value from the array.

从数组中获取随机值。

回答by James Leatherman

The answer depends on whether or not every listbox element is a valid selection. If the first element of the listbox is instructional ("Please select...", etc.), you need a snippet of code:

答案取决于每个列表框元素是否都是有效选择。如果列表框的第一个元素是说明性的(“请选择...”等),您需要一段代码:

Option 1:(when a “Please select” is present)

选项 1:(当出现“请选择”时)

In the step's 'Arguments' section, Set Ordinal to:

在步骤的“参数”部分,将序数设置为:

var objectIndex = Math.floor((object.length-1)*Math.random())+2;
objectIndex;



Option 2:(when a “Please select” is not present)

选项 2:(当“请选择”不存在时)

In the step's 'Arguments' section, Set Ordinal to “0”.

在步骤的“参数”部分,将序数设置为“0”。

回答by NaveenKumar Namachivayam

Generate a random number in runtime and put that variable in the Ord= parameter. E.g.

在运行时生成一个随机数并将该变量放入 Ord= 参数中。例如

a = Rand(1,100)
lr_save_param("{myrandval}",a);
Web_custome_request("",
"",
"",
"Ord={myrandval}",
LAST);