Friday, July 6, 2007

search for a Webobject in a webtable and to click the webobject

''Name : fnSearchAndClickTab(objTable,strSearchValue)
''Description: This function is used to search for a Webobject in a webtable and to click the webobject and returns true.If Webobject is not present then it return false.
''Arguments: : Web Table object
'' : webElement that needs to be clicking in the screen
''Example:
'' Set objTable=Browser("Capital One").Page("ProphIT - 7560 - COF -").Frame("WorkFlowFrame").WebTable("Workflow")
'' strSearchValue="Add Notes"
''Return true/False
'Pre-Condition: nil
'Post-Condition:nil
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''Only for Tab order
Public Function fnSearchAndClickTab(objTable,strSearchValue)
fnSearchAndClickTab=False

Dim intRowCount
Dim intColumnCount
Dim strFromScreen
Dim objChild
Dim intRowLoop
Dim intColumnLoop
Dim intChildCount

Set objFrame=objTable
Set objPage=Browser("Chordiant").Page("Chordiant")
Call fnSynchroniseObjects(objPage,objFrame,20)
Browser("Chordiant").Page("Chordiant").sync

If isObject(objTable) and objTable.exist(0) Then' This will check for the object name

intRowCount = objTable.RowCount ' This will get the row count in that table
If not intRowCount=0 Then ' This will check whether the table is present or not

For intRowLoop =1 to intRowCount ' this navigates inside the table based on the row count

intColumnCount= objTable.ColumnCount(intRowLoop) ' this get the column count by giving the row number
For intColumnLoop = 1 to intColumnCount ' this navigates inside the table based on the column count
strFromScreen=objTable.GetCellData(intRowLoop,intColumnLoop) ' this get the value from the screen
If strcomp(trim(strFromScreen),trim(strSearchValue),1)=0 Then ' this compares the value from screen with value given

intChildCount=objTable.ChildItemCount( intRowLoop,int(intColumnLoop), "WebElement")' Verify for Webelement insite that table and gets count of it

If intChildCount<>0 Then
Set objChild=objTable.ChildItem (intRowLoop,int(intColumnLoop), "WebElement", 0)' Creates child element object
objChild.click ' selects the child element object
fnSearchAndClickTab=True
intRowLoop=intRowCount
intColumnLoop=intColumnCount
exit function
Else
Set objChild=objTable.ChildItem (intRowLoop,0, "WebElement", 0)' Creates child element object
objChild.click ' selects the child element object
fnSearchAndClickTab=True
intRowLoop=intRowCount
intColumnLoop=intColumnCount
exit function
End If

End If
Next
Next

End If
End If

Set objTable=nothing
End Function

No comments: