Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP 9.5 - Select an element in a table
#1
Hello,

I would like to select one precise element in a table (a JTable in fact but I think it's quite similar) and I don't know how to do it.

For example, if I have the table :
Code:
Column 1 | Column 2 ----------------------- z | Name1 k | Name2 b | Name3 d | Name4

How can I select the name in "Column 2" which correspond to the line which contains 'k' in "Column 1" ?

Of course this line is not always the second.

Thanks in advance !
Reply
#2
Hi SAKDOSS ,
Code:
If Browser(X).Page(X).WebTable("index:= Here mention UR table index").Exist Then ColNum = Browser(X).Page(X).WebTable("index:= Here mention UR table index").ColumnCount(1) DesiredColNum = 0 For colint = 1 to ColNum If Browser("SAM").Page("SAM").WebTable("Database:").GetCellData(1,colint) = "Column2" Then DesiredColNum = colint Exit For End If Next If DesiredColNum <> 0 Then For rowint = 1 to Browser("SAM").Page("SAM").WebTable("Database:").RowCount rowval = Browser("SAM").Page("SAM").WebTable("Database:").GetCellData(rowint,1) If rowval = "k" Then DesiredRow = rowint Exit for End If Next Else MsgBox "Column2 is not displayed in the specified table." End If MyValue = Browser("SAM").Page("SAM").WebTable("Database:").GetCellData(rowint,DesiredColNum) msgbox MyValue Else msgbox "Specified WebTable with ''" & Here mention UR table index & "'' is not present." ExitRun End If

Please let me know if you need any more info.
Thanks,
SUpputuri
Reply
#3
Please see the attached document and go through the query so that u would feel much comfortable
Scenario:

When I record the application it is taking same object multiple times like “+” is a grow button then in object repository it is taking multiple times as growbutton_1, growbutton_2, growbutton_3,…..
And the same way for the fields (area, assigned to, originator) which is taking as “Select field”, selectfield_1, selectfield_2,……

While running the application as in OR it is having multiple object and able to run successfully when I use the descriptive programming it is not running successfully

My observation:
While running the application here in the first field it is taking as Area and select the field values and next it has to perform the clicking “+” button and then it has to select the another field from the second field
Observed issue:
Here it is always selecting the first field value only instead of 2,3,4,…..


Could you please share your ideas please let me know if u have any better solution for this
Thanks,
Venkat.Batchu


Attached Files
.doc   forum.doc (Size: 48.5 KB / Downloads: 135)
Reply
#4
Thank you very much QTPKing.

I'm using a JTable so I modify a little bit your script (I also changed the For loops into While loops).

Code:
'String which enable to identify the line id = "090701224501893r" 'Column where we will search id colIdLabel = "FIX.4.2" 'Column of the expected value colExLabel = 8 If JavaWindow("Log Message").JavaTable("MessageTable").Exist Then nbCol = JavaWindow("Log Message").JavaTable("MessageTable").GetROProperty("cols") 'We are trying to find 2 columns (one for the id and one for the expected value) nbFindCol = 0 'Find the expected columns i = 0 While nbFindCol<2 and i<nbCol If JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(0, i) = colIdLabel Then colIdNum = i nbFindCol = nbFindCol +1 End If If JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(0, i) = colExLabel Then colExNum = i nbFindCol = nbFindCol +1 End If i = i+1 Wend If nbFindCol <> 2 Then msgbox "Error : one of the column has not been found" Else nbRow = JavaWindow("Log Message").JavaTable("MessageTable").GetROProperty("rows") 'Find the expected row i = 0 found = false While found = false and i<nbRow If JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(i,colIdNum) = id Then rowExNum = i found = true End If i = i + 1 Wend msgbox JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(rowExNum,colExNum) End If Else msgbox "The Java Table doesn't exists" End If
Reply
#5
that's great SAKDOSS
Thanks,
SUpputuri
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Page element keep changing chong67 4 5,329 11-08-2016, 09:17 PM
Last Post: Paul Rammone
  Choosing element from array marvson 1 2,429 06-29-2016, 02:55 PM
Last Post: Ankesh
  Web Element: Not able to select value from drop down in Web Element. Rajeev 4 6,086 08-04-2015, 06:03 PM
Last Post: kbhargava505
  Multi Select in UFT/ QTP vanga 0 3,902 02-25-2015, 07:03 PM
Last Post: vanga
  How to capture tool tip within a web element frebuffi 3 4,382 11-10-2014, 10:06 AM
Last Post: learning_UFT

Forum Jump:


Users browsing this thread: 1 Guest(s)