Visual Basic
' Find the first table on the page.
Dim outertable As HtmlTable = Find.ByTagIndex(Of HtmlTable)("table", 0)
Assert.AreEqual(3, outertable.Rows.Count)
' Find the first table inside the outer table
'
' Note: HtmlContainerControls have a Find object
' associated with them that scopes all the Find.Byxx searches
' to elements contained within them only.
' So even if you have multiple controls with similar contained
' elements, this will help avoid any conflicts.
' Also, note how we are referencing the innertable Imports index 0
' since it is the first table inside our outer table.
'
Dim innerTable As HtmlTable = outertable.Find.ByTagIndex(Of HtmlTable)("table", 0)
' Special Find for tables. Find the first cell of the inner table that contains the text "TD21"
Dim cell As HtmlTableCell = innerTable.Find.TableCell("TD21")
Assert.IsTrue(cell.TextContent.Equals("TD21"))
' Find all HtmlInputImage controls with 'src' containing partial value 'logo'
Dim imgCtrls As IList(Of HtmlInputImage) = Find.AllByAttributes(Of HtmlInputImage)("src=~logo")
' There should only be one HtmlInputText control. All controls
' That match the attribute list but fail validation by the HtmlInputText control
' will be ignored.
Assert.AreEqual(1, imgCtrls.Count)
' Find the <div> section containing the Eastern US Division sales report
Dim EasternUSDivision As HtmlDiv = Find.ByContent(Of HtmlDiv)("Eastern US Division", FindContentType.TextContent)
Assert.IsNotNull(EasternUSDivision)