Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..
765 views

AJAX Truclient checkbox selection for same set

AJAX Truclient checkbox selection for same set

There are two different set of checkboxes (InStock & outStock). 

Business flow is to select all the Instock checkboxes on the page(Instock checkboxes numbers will change with different user) and click next button on the button of the page.

Could you please let me know how to select all the Instock Checkboxes and move forward.

Please find the screenshot attached.

Instock_outstock.jpg

 

Regards,

Sai

0 Likes
7 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: AJAX Truclient checkbox selection for same set

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: AJAX Truclient checkbox selection for same set

Hello Edo,

 

Could you please elborate more.

how to write a for loop, as i don't know the no. of values on the page(this values changes per user).

could you please give javascript snippet so that i can try and come back to you.

 

Regards,

Sai

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: AJAX Truclient checkbox selection for same set

Hi Sal,

In TruClient, the "for" loop's end condition is a Javascript code, so you can loop over collections of any size. Simply evaluate the collections size in the "Condition" section of a "For" step arguments.

Doing this via Javascript will require iterating over the collection of items and triggering the checkbox's "checked" property.

In general, to implement Javascript code, I would suggest to brush up on Javascript.

 

Edo

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: AJAX Truclient checkbox selection for same set

Hello Edo,

When i click the Hightlight button i can see the "In stock" values are highlighted.

Below is the xpath i used:

//td[.='In Stock']/following-sibling::td[position()=1]//input[@type="checkbox"]

please find the screenshot.

instockhighlighted.jpg

how can i add EvalXpath value into for loop javascript condition.

As a user i need to select the checkbox of all "Instock"

i understand it should be in this format

Step 1: length of Instock values  and place in length value in for loop condition

step 2: select one by one checkboxes by getting value from for loop.

step 3: move to next page.

But i need some snippet for step1 and step2.

thanks again.

Regards,

Sai 

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: AJAX Truclient checkbox selection for same set

Anybody can help me to write "For" loop in javascript for the above condition.

 

 

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: AJAX Truclient checkbox selection for same set

Hello Edo,

Could you please help me to write the condition for the FOR loop. 

Please find the screenshot.

I have selected a number and it selects all the values of requirement, but it is hardcorded. what i need is length of number so that the for loop iterates only to the length.

selection.jpg

Thanks

Regards,

Sai

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: AJAX Truclient checkbox selection for same set

To find the number of values ("In stock") on the page.

i did evaluate javascript before for loop and added below code

var count =evalXPath("//td[.='In Stock']/following-sibling::td[position()=1]//input[@type=\"checkbox\"].length");
window.alert(count);

but i see evalXpath is not defined.

Regards,

Sai

0 Likes
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.