Highlighted
Absent Member.
Absent Member.
1704 views

AJAX Truclient on checkboxes

Jump to solution

Hello All,

 

I have few issues in AJAX Truclient.

 

Question 1:We have requirement in AJAX Truclient scripting like there are random number of checkboxes, where we have to select the In-stock product and move further. But the In-stock checkboxes vary with different users.

I know how to handle this with web(HTTP/HTML) protocol, here we are using AJAX Truclient protocol. so can anyone help me how to handle this.

Question 2: Selecting a radio button randomly, below is the XPath

//input[@type="radio" and @name="outFlight" and @value="Blue Skies Airlines$360$270$5:03"]

//input[@type="radio" and @name="outFlight" and @value="Blue Skies Airlines$361$271$7:10"]

//input[@type="radio" and @name="outFlight" and @value="Pangea Airlines$360$270$5:03"]

if the value is some integer number we can do randomize but the value is some names. so how to handle this situtation.

 

Regards,

Sai

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: AJAX Truclient on checkboxes

Jump to solution

Hi Sai, 

 

If you record a few steps clicking on different radio button, open the steps and change the ID Method to JavaScript in the step object section you will see a code similar to the one below:  

evalXPath("(//input[@type=\"radio\" and @name=\"outFlight\"])[1]");

 

All you need to do is to substitute the 1 which indicates the radio button which was selected with a random value. 

evalXPath("(//input[@type=\"radio\" and @name=\"outFlight\"])["+randomID+"]");

 

You can use JavaScript Math.random()function to get the random number.

Additionally if the number of elements is changing you can use a javascript functiont to select all radio buttons for example and get their number for example using the following function:
 document.querySelectorAll(...).length. 

 

 

You can find detailed step by step  instructions in the following knowledge document:

https://softwaresupport.hp.com/group/softwaresupport/search-result/-/facetsearch/document/KM01788615

 

Kind regards,

Vesela

HPE Support
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.

View solution in original post

0 Likes
7 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: AJAX Truclient on checkboxes

Jump to solution

Hi Sai, 

 

If you record a few steps clicking on different radio button, open the steps and change the ID Method to JavaScript in the step object section you will see a code similar to the one below:  

evalXPath("(//input[@type=\"radio\" and @name=\"outFlight\"])[1]");

 

All you need to do is to substitute the 1 which indicates the radio button which was selected with a random value. 

evalXPath("(//input[@type=\"radio\" and @name=\"outFlight\"])["+randomID+"]");

 

You can use JavaScript Math.random()function to get the random number.

Additionally if the number of elements is changing you can use a javascript functiont to select all radio buttons for example and get their number for example using the following function:
 document.querySelectorAll(...).length. 

 

 

You can find detailed step by step  instructions in the following knowledge document:

https://softwaresupport.hp.com/group/softwaresupport/search-result/-/facetsearch/document/KM01788615

 

Kind regards,

Vesela

HPE Support
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: AJAX Truclient on checkboxes

Jump to solution

Hello,

 

I clicked on other radio buttons to check the number changes at end and tried javascript ID Method of the Object. But still the problem persist. 

 

Please find below javascript ID Method

 

evalXPath("//input[@type=\"radio\" and @name=\"outFlight\" and @value=\"Blue Skies Airlines$361$271$7:10\"]");
evalXPath("//input[@type=\"radio\" and @name=\"outFlight\" and @value=\"Pangea Airlines$362$274$9:17\"]");

 

Here there is NO numerical value which i can change , they are assigned with some names. 

 

So please let me know what's next steps need to do to get random value from the radio which consists of names.

 

Thanks,

Sai

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: AJAX Truclient on checkboxes

Jump to solution

Hi Sai

 

Have you tried to use evalXPath("(//input[@type=\"radio\" and @name=\"outFlight\"])[1]"); ? 

What is the outcome?

 

I have tested the above suggestion  with the xpaths you have provided  and it works without issues for me as 

evalXPath("(//input[@type=\"radio\" and @name=\"outFlight\"])[1]"); selects the first input element with type "radio" and name "outFlight" 

evalXPath("(//input[@type=\"radio\" and @name=\"outFlight\"])[2]") selects the second one, etc. 

 

 

Kind regards, 

Vesela 

HPE Support
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: AJAX Truclient on checkboxes

Jump to solution

Thanks vesela...

 

Question 2 got resolved and really appreciate the way you helped me to resolve. 

 

But still question 1 is not resolved.

 

on single page with labels i get like Instock and Outstock radio button i need to select only Instock.. i have handled this situtaion in WEB protocol.

 

i have selected both Instock and Outstock to see the difference but didn't find any.

 

Outstock
evalXPath("//input[@type=\"checkbox\" and @value=\"354167eaacff48a121b550eb869ca5ea6977\"]");
evalXPath("//input[@type=\"checkbox\" and @value=\"35413ad2b983efab3ad18d337cdca65b4442\"]");
evalXPath("//input[@type=\"checkbox\" and @value=\"354156503f1383d68ec8185e2ac9f067e818\"]");

InStock
evalXPath("//input[@type=\"checkbox\" and @value=\"979993487c813989c6d10f3b969314e9428b\"]");
evalXPath("//input[@type=\"checkbox\" and @value=\"9799b6e79982de8a21965cda70c745936d41\"]");
evalXPath("//input[@type=\"checkbox\" and @value=\"979977ad4fc2372179805c8500bde964b1cb\"]");

 

Any help on this highly appreciated.

 

Thanks,

Sai

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: AJAX Truclient on checkboxes

Jump to solution

Hi, 

 

You can use the labels associated with the checkbox or use something specific in the value which differs the elements you need. 

In the xpath below the difference is that the elements you need start with 979:

 

evalXPath("//input[@type=\"checkbox\" and @value=\"979993487c813989c6d10f3b969314e9428b\"]");

 

You can select the first element with a value containing  "979"

evalXPath("//input[@type=\"checkbox\" and contains(@value,\"979\")][1]");

 

or select the second  element  with a value starting  with "979"

evalXPath("//input[@type=\"checkbox\" and starts-with(@value,\"979\")][2]");

 

 

Kind regards, 

Vesela 

HPE Support
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: AJAX Truclient on checkboxes

Jump to solution

Hello Vesela... 

 

i have recorded the script once again to see the differences in IN Stock  & Out Stock. but the values of both the checkboxes are similar.

 

 

 

 

Please find the screenshot

1)What i need to do in this test case is. we need to check only the IN Stock checkboxes( how to differentiate INStock and Outstock in step1.

2)The number of IN stock checkboxes are random with user we login, Selecting all the IN stock checkboxes (Once IN Stock is differentiated from then find all the Instock and go to next navigation.

 

Below are the evalXpath and javascript for both IN & OUT boxes

OUT checkbox

//input[@type="checkbox" and @value="8539a871e630eb852ff118625756a3f3e73d"]
evalXPath("//input[@type=\"checkbox\" and @value=\"8539a871e630eb852ff118625756a3f3e73d\"]");

 

IN Checkbox

//input[@type="checkbox" and @value="85398b766eb1f7e41e15c11ce90df3e2a7fd"]
evalXPath("//input[@type=\"checkbox\" and @value=\"85398b766eb1f7e41e15c11ce90df3e2a7fd\"]");

 

Thanks & Regards,

Sai

 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: AJAX Truclient on checkboxes

Jump to solution

Hi Sai,

 

The out of stock and  in stock elements are probably put in different parent elements.

You should review the html code.

 

Additionally you can check if the XPath method will show the difference.

For example if they are put in different divs the xpath will look something like this:

/html/body/div/form/div[4]/input[1]

/html/body/div/form/div[5]/input[1]

 

 

Kind regards,

Vesela

HPE Support
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.
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.