AJAX Truclient on checkboxes

Question ID: 106343

Hello All,

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.

@davidmofosi – appreciate if you can answer with some screenshots
Thanks in advance.

Marked as spam
Posted by (Questions: 2, Answers: 0)
Asked on August 17, 2015 5:10 pm
Answers (1)
Private answer

ANSWER to Question 1 :
Use a loop to count the number of checkboxes and then to check the correct ones

ANSWER to Question 2:

Step 1. Record the step for selecting the radio buttons. (if 3 radio buttons record all 3)

Step 2. Select the 1st step and expand it. Make the 3 ID Methods are displayed. The 3 ID Methods have the following information for the 3 Radio Buttons.


* //input[@type=''radio'' and @value=''187309'']
* //input[@type=''radio'' and @value=''187317'']
* //input[@type=''radio'' and @value=''187325'']

X Path Values:

* //div[@id=''radioContentWrapper'']/input[1]
* //div[@id=''radioContentWrapper'']/input[2]
* //div[@id=''radioContentWrapper'']/input[3]


* evalXPath(''//input[@type=''radio'' and @value=''187309'']'');
* evalXPath(''//input[@type=''radio'' and @value=''187317'']'');
* evalXPath(''//input[@type=''radio'' and @value=''187325'']'');

Steps 3:Consider the JavaScript method of 1st Radio Button. Paste the XPath value into the evalXPath step (within the quotes) so it now looks like this:

* evalXPath(''//div[@id=''radioContentWrapper'']/input[1]'');

Step 4: Escape the quotes ('') in the XPath expression by preceding them with a backslash () so this now looks like this:

* evalXPath(''//div[@id=''radioContentWrapper'']/input[1]'');

Step 5: To get all the radio buttons we remove the ordinal ([1]) so we now get:

* evalXPath(''//div[@id=''radioContentWrapper'']/input'');

Step 6: Assign this expression to a variable called options (any variable name can be used) that will become an array containing all the elements matching the XPath we defined:

* var options=evalXPath(''//div[@id=''radioContentWrapper'']/input'');
Step 7: To randomly select the radio buttons, add the below expression.

* random(options);

The final JavaScript should look like,

* var options=evalXPath(''//div[@id=''radioContentWrapper'']/input'');
* Random(options);

Step 8: Use 'Highlight' option to test whether the radio buttons are selected randomly. Results are shown after clicking on the 'Highlight' button.

Step 9: Run the script with commenting out the other 2 radio buttons and see the results.

Happy testing

Marked as spam
Posted by (Questions: 12, Answers: 363)
Answered on June 27, 2016 2:39 pm