This is a migrated thread and some comments may be shown as answers.

HtmlTableCell Find by Search String

1 Answer 136 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 27 Feb 2012, 09:05 PM

I have the following code that searches a table that can be indexed by pages.  What I do not know what is the return value of myTable.Find.ByContent when the search string is not matched.  Also what’s a slick way to do an index search in the pages till the string is found.  I want to mimic what a user would do in index.

Thanks,

John

Dim MySearchString as String
MySearchString = "Start All over III"
 
 
 
' Copy the table into a local variable to make it easier to work with
Dim myTable As HtmlTable = Pages.JointCommissionResources9.CphTracerPageRadMyOrgTracesTable
' Locate the row we want using text content (Enter the String to search by
Dim row As HtmlTableRow = myTable.Find.ByContent(Of HtmlTableCell)(MySearchString).Parent(Of HtmlTableRow)()
 
' Locate the delete icon (which is going to be just an anchor tag) located in the third column of the current row
'Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnEditResponse")
'uniquename="UrgbtnNewResponse"
Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnNewResponse")
'Dim link As HtmlAnchor = row.Cells(4).Find.ByExpression(Of HtmlAnchor)("value=Print/Preview")
' Now that we've found it, click the delete icon
link.Click()
 
HtmlTableCell Find By Search String
 
Dim MySearchString As String
Dim PageNumber As Integer
 
 
MySearchString = "this is a new tracer"
Log.WriteLine("Value: " & MySearchString)
Log.WriteLine("Pages: " & GetExtractedValue("x2StrongTag").ToString())
 
 
 
' Copy the table into a local variable to make it easier to work with
Dim myTable As HtmlTable = Pages.JointCommissionResources9.CphTracerPageRadMyOrgTracesTable
Log.WriteLine("Table when Nothing found: " & myTable.ToString)
 
' Locate the row we want using text content (Enter the String to search by
'Dim row As HtmlTableRow = myTable.Find.ByContent(Of HtmlTableCell)("Article B01").Parent(Of HtmlTableRow)()
 
 
 
Dim row As HtmlTableRow = myTable.Find.ByContent(Of HtmlTableCell)(MySearchString).Parent(Of HtmlTableRow)()
 
' Locate the delete icon (which is going to be just an anchor tag) located in the third column of the current row
'Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnEditResponse")
'uniquename="UrgbtnNewResponse"
Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnNewResponse")
'Dim link As HtmlAnchor = row.Cells(4).Find.ByExpression(Of HtmlAnchor)("value=Print/Preview")
' Now that we've found it, click the delete icon
link.Click()

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 01 Mar 2012, 10:14 PM
Hello John,

That will return a null reference exception if the search string isn't matched. See our code sample article on HTML Table Searching & Paging for an example on how to accomplish this against a Telerik demo site.

Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
John
Top achievements
Rank 2
Answers by
Anthony
Telerik team
Share this question
or