Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
one column of table rows has links - want to access them - any ideas?
#1
Solved: 11 Years, 4 Months ago
Situation: A table in a page displays requirement items to be (mentioned/saved) completed. Test should complete all of them more or less one by one. Two types of requirements: To complete one of the types, check the checkbox and click save; To complete the other type (which would not have checkbox), select the row (by clicking a link in the row) and navigate to different page to complete the process.

Skip this section - Please use this section to further understanding:
Assume a table with some #rows. Total number of rows change, so only after the page loads we know. #columns with column title is fixed (which is 6). As far as the data in each row, there are two types of rows.
1. rows that have a checkbox in the first column.
2. rows that do not have a checkbox in the first column
Both type of rows have a link (in order to select the row for further processing) at the 3rd column.

The test should do the following 2 steps:
Step 1: Set the checkbox checked on all the checkbox rows and click a button (save). This button is in the same page but not in this table. Clicking this save button/link is easy as it is unique. Clicking Save reloads the same page. [Advantage: these are the only checkboxes in the page. Again, order does not matter, test needs to check all of them and click the save button/link]
Step 2: Select (click on the link at 3rd column of the row) the rows (that do not have checkboxes) one by one and navigate to different page to do a process and get back. Repeat step 2 untill all such rows are done. [Advantage: navigation link to further process will not be visible or available until the rows is selected]


Could you please give me some scripting ideas for the following:

1. Can I find out total # of checkboxes and access individually to set them checked? Any script ideas...
2. Similarly finding #of rows (that do not have checkboxes), then click in the order they appear to do process?


Appreciate your ideas and time Smile
Reply
#2
Solved: 11 Years, 4 Months ago
Please refer to the ChildItem method of the WebTable object under QTP help. You would need to use this method for the CheckBox as well as the Link:

Code:
'CheckBox
.ChildItem(iRow, iCol, "WebCheckBox", iIndex)

'Link
.ChildItem(iRow, iCol, "Link", iIndex)

The 3rd parameter points to the ClassName of the object. 4th is the index relative to the number of similar objects present in the cell.

You can retrieve the number of rows and columns using RowCount/ColumnCount or GetROProperty. You would need to run a loop from the row below the header (generally 2) to the last row/column combination and check for CheckBoxes as well as the links. It should be something like this:

Code:
Const row = 2 '2 because generally the 1st row is the row header
Const col = 1
Dim iRows, iCols
Dim r, c

iRows = Browser("").Page("").WebTable("").GetROProperty("rows")
iCols = Browser("").Page("").WebTable("").GetROProperty("cols")

For r = row to iRows
    For c = col to iCols
        'Check if the cell contains a checkbox
        'You can also write an else for a condition when the checkbox does not exist
        If Browser("").Page("").WebTable("").ChildItem(r, c, "WebCheckBox", 0).Exist(0) Then
            'Check the checkbox in the cell
            Browser("").Page("").WebTable("").ChildItem(r, c, "WebCheckBox", 0).Set "ON"
        End If
    Next
Next

You could run a similar code for the Link..

I hope this helps a little.
Reply
#3
Solved: 11 Years, 4 Months ago
Thank you so much
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple rows of test data Bhuvana 0 1,337 01-03-2020, 09:30 PM
Last Post: Bhuvana
  [UFT] Get column name from SfwObject felino 0 3,013 12-02-2015, 04:07 PM
Last Post: felino
  Adding data into rows that add dynamically with setcelldata azar81 4 5,916 04-13-2015, 05:24 PM
Last Post: vidya2k2
  Excel operation - to find usedrange of rows & col pooja 1 9,707 02-19-2015, 04:06 AM
Last Post: supputuri
  how to count rows and columns in csv file. venkatesh9032 1 2,798 02-18-2014, 01:28 AM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)