TESTEVERYTHING

Saturday 23 July 2011

Select the row in WEBTABLE/WEBGRID using QTP/DOM

Hi All,

I found that most of time while working with WEBTABLE we need to the select the row based on some criteria by clicking checkbox or radiobutton.For that first we have to find the row which we have to select based on value of that row like text/link inside the row.
Here I am giving an example how to select a row in Webtable by finding the text. Logic I am using here is first i will find the row number from webtable where my searching text is present using GetRowWithCellText method then I will provide the column name/index of webtable where checkbox is present.



In below mentioned example I will select the row where Confirmation Number is "15204"
Let's see




Select Date ConfirmationNumber User Name Organization Name


17-SEP-2008

13761


 SMITH'S LP SUPPLY CO. 


24-OCT-2008

13808


 Micro Motion test1 


30-OCT-2008

13874


 EMERSON PROCESS MANAGEMENT ASIA PACIFIC PTE LTD 


13-JUN-2009

15058


 Spartan Controls Ltd. 


08-AUG-2009

15204


 Emerson Process Management 

REM find the row number  where "15204" text is present using GetRowWithCellText method

GtRowN = Browser("XYZ").Page("OBC").WebTable("Request Summary").GetRowWithCellText("15204")

REM check text find in webtable or not
     If  GtRowN >0 Then
   
          REM  coulmn index  where  checkbox  is present
          Rem here select coulmn name index value is 1
          CoulmnIndex = 1 
         
    REM create the checkbox object  after getting the rownumber and select the row by clicking the checkbox


            set objCheckbox = Browser("XYZ").Page("OBC").WebTable("Request Summary").ChildItem(GtRowN,CoulmnIndex,"WebCheckBox",0)
       
           objCheckbox.set "ON"
       
    else
         msgbox "Did not find the value test fail"
     End If

8 comments:

QPT said...

Hi,

First of all want to Thank You for your useful post.
This Software Testing article is very useful for me. I would like to introduce another good site which is having Software testing and QTP content, Have a look.
QTPbook

Anonymous said...

Thank you it was very useful :)

Anonymous said...

Thnks much... it worked for me... here is my code... but I think VSTS Automation is a much better tool where we can handle all such things very easily..

intRowNum = browser("General Documents").Page("General Documents").WebTable("Docs").GetRowWithCellText("SRS")
If intRowNum > 0 then
Set lnkFile = browser("General Documents").Page("General Documents").WebTable("Docs").ChildItem(intRowNum,2,"Link",0)
lnkFile.Click
else
msgbox "SRS not found"
end if

Anonymous said...

Here is the VSTS Automation code for it, using C#...

foreach (HtmlRow row in this.mUIGeneralDocumentsWindWindow.UIGeneralDocumentsDocument.UIOnetidDoclibViewTbl0Table.Rows)
if (row.InnerText.Contains("SRS") == true)
Mouse.Click(row, row.GetClickablePoint());

Anonymous said...

how to perform the same task using Web Grid?

Anonymous said...

gr8 article, thanks a lot...

Anonymous said...

Good Article...It worked for me but I didnt get where we have used DOM?Please explain brifly as I am new to the QTP and I dont know abt DOM.Thanks.

Anonymous said...

Thanks for the info but it is not working as displaying "Object Required Error" .

Post a Comment

Which one is right ?

Translate







Tweet