Ask a Question

Select checkboxes based on the content of their siblings

halovski
Contributor

Select checkboxes based on the content of their siblings

Capture6.PNG

How do I make a keyword test that clicks one of the checkboxes, by using some of the textContent on its line in the sibling elements? For example clicking the first checkbox if we give TestComplete an input of 13.99, or the second one if we give it an input if 5.05

5 REPLIES 5
rraghvani
Champion Level 3

Assuming that control is a table - if you search for each row, where the fourth column equals "5.05". Then you can do e.g. Cell(row, 1).ClickButton(cbChecked)

Capture8.PNG

 If we get the cell coordinates from a get statament, what type of operation would we need to use in? Where would we need to write our version of "Cell(row, 1).ClickButton(cbChecked)''

rraghvani
Champion Level 3

If you use the Object Spy tool or the Object Browser, look at the property value of cellIndex of your cell, the value will most likely indicate its cell position within the table.

 

The benefit of keyword tests is that in many cases it is easier and faster to create them than to write the script. However, the number of actions you can perform in keyword tests by using the operations is limited and sometimes it may be more convenient to run script code to perform tasks. You can call script routines from keyword tests.

 

Note, if you take the approach of searching for e.g. 13.99, there may be more than one entry matching that criteria.

Capture9.PNG

This is what I came up with. The only thing left for me to do is to get "clientRow" dynamically depending on my input. How can I get clientRow to give me 1 if my number is located on the 1st row and 2 if its located on the 2nd?

rraghvani
Champion Level 3

Here's a simple example,

rraghvani_0-1685608642563.png

Where I search for the value "$1.99" in the table. The returned item, has the property RowIndex. To which I then highlight the appropriate cell

cancel
Showing results for 
Search instead for 
Did you mean: