This method is used to make visible the collection of DIV tags on a web page. DIV elements contain a host of properties to help manipulate the information therein.
Example of Usage
This example utilizes the main.html page that is distributed with WatiN to highlight some of the methods available with the DIV class.
''' <summary>
''' Test behavior of DIVs
''' </summary>
''' <remarks>
''' currentURL is a Private Const =
''' "http://localhost:3587/main.html"
''' </remarks>
<Test()> _
Public Sub TestDivs()
Dim aDIV As Div
Dim aBoolean As Boolean = False
Dim aString As String = ""
Using ie As IE = New IE(currentURL)
For Each aDIV In ie.Divs
If aDIV.Text.Contains("Contains text in DIV") Then
aBoolean = True
Assert.IsTrue(aDIV.Tables.Length > 0, "DIV did not contain any tables.")
Exit For 'Found DIV in question, no need to look at the rest of them.
End If
Next
Assert.IsTrue(aBoolean, "Div did not contain expected text.")
End Using
End Sub
This test shows the most common use of the DIVS method, which is finding a DIV that does not have a known ID. Each DIV tag on the page is examined to match some known aspect (normally text) to locate the correct DIV, and then the DIV itself can expose the remainder of its properties for testing.
Contents: Table of Contents Previous Page: WatiN API Reference - Div Next Page: working on it