TESTEVERYTHING

Showing posts with label WebTable. Show all posts
Showing posts with label WebTable. Show all posts

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

Wednesday, 22 June 2011

Validation of Sorting in WEBTABLE / QTP

Hi All,
Some time in application we have to verify the sorting functionality.In Web table for each column we need to click and check is it working fine or not. Here i am giving an example of sorting the date column. but it will verify in ascending order.

logic for this:
  1. Click on Date column which sort the date in ascending order.
  2. Get first row and second row date value form Date column
  3. Check first row date should be less than or equal to second row date.
  4. Get second row and third row date value.
  5. Check second row date should be less than or equal to third row date value.
  6. Same way check until end of row using For Loop.
  7. In the case if you got false result while comparison two row you need to break the for loop and show  the   fail result......

set TableObject = Browser(“XYZ”).Page(“WXY”).WebTable(“MNP”)
TableRowcount  = Browser(“XYZ”).Page(“WXY”).WebTable(“MNP”).RowCount

For i =1 to TableRowcount -1
 dtmCurrRow  = TableObject.GetcellData(i,<DateColumn>)

 dtmNextRow  =  = TableObject.GetcellData(i+1,<DateColumn>)
      If  NOT cdate(dtmCurrRow) <=  cdate(dtmNextRow) Then
              Flage = 1
              Exit For
      End If
End
If  Flage <> 1 than
  msgbox  "Pass"
Else
  msgbox  "Fail"
End if

Wednesday, 15 June 2011

Get cell data from webtable / QTP

Hi all ,
I found a helpful example in QTP  help file that can be use most of time while working with web table. I hope It will help you.

Description

       Returns the text contained in the specified cell.

Syntax

   object.GetCellData (Row, Column)
Argument Description
object A test object of type WebTable.
Row Required. A Variant value. The row number where the cell is located. The first row in the table is numbered 1.
Column Required. A Variant value. The column number where the cell is located. The first column in the table is numbered 1.

Return Value

A String value.  Returns the data contained in the specified cell.
If the specified cell is not valid, the method returns micCellDoesNotExist
Find All Employees That Live in the Same City

Sub GetCellData_GetRowWithCellText_Example()
        ‘The following example retrieves the names of all employees that live in
       ‘the same city as John Smith so that he can arrange rides home with them.
       ‘First, the example finds the table row containing
      ‘”John Smith”. Then it checks the value of the CityColumnn cell to determine
       ‘the city in which John lives. It searches the table cells to find all other
        ‘employees that live in that city. Finally it uses the GetCellData method to
        ‘return those employees names and, using a function, generates a list
         ‘containing those names.

  CityColumn = 4
  NameColumn = 2

‘Get the row number for employee ‘John Smith’
RowNumber = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetRowWithCellText(“John Smith”)
Set AccommodationsCity = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(RowNumber, CityColumn, “WebEdit”, 0)
TableRows = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).RowCount
‘Search for all employees that live in the same city as ‘John Smith’ and add them to his ride home list
For i = 1 To TableRows
   Set CurrentCity =    Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(i, CityColumn, “WebEdit”, 0)
    If CurrentCity.GetROProperty(“value”) = AccommodationsCity.GetROProperty(“value”) Then
      EmployeeName =  Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetCellData(i, NameColumn)
      AddToJohnSmithRideHomeList (EmployeeName)
     End If

 Next
End Sub

Which one is right ?

Translate







Tweet