Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Highlighted
agks7 Regular Contributor.
Regular Contributor.
86 views

How to fill all input text fields on the page with one value in Truclient Loadrunner

I need to fill all text inputs on the page with one value. Script on TrueClient Loadrunner. each time we have on the page a different number of fields. Therefore, you cannot use the name of the input.
For example, we have on the page:
<input type="text" name="gagahvdjjxj6"/>
<input type="text" name="ghdkk448"/>
<input type="text" name="764hjxuz"/>

We have to fill 3 input text by one value ("test").
How can I get this?
0 Likes
1 Reply
Nakkeeran Valued Contributor.
Valued Contributor.

Re: How to fill all input text fields on the page with one value in Truclient Loadrunner

Hi @agks7 

Add 'Evaluate JavaScript' component from toolbox and use below javascript code.

 

var textBoxCount = AUT.document.querySelectorAll("input[type='text']").length;

for (i=0; i<textBoxCount; i++)
{
AUT.document.querySelectorAll("input[type='text']")[i].value="test";
}

Edit: I think based on LR version, you may want to exclude 'AUT.'

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.